Generation of the invoice. PDF Conversion with SharePoint workflow.

5
(3)

This article describes how to create a SharePoint Workflow which automatically generates and sends invoices to email recipients. The invoice will be generated and sent as soon as a new item is added into the list. This kind of workflow cannot be created using any standard actions and conditions which are available in SharePoint, so we will use some actions added by HarePoint Workflow Extensions for SharePoint:

Component name and type Set of Workflow components
SharePoint Workflow HarePoint Workflow Extensions
Copy or Move Documents (action)
Update Word Document (action)
Convert Document (action)
Wait Conversion Job (action)
Delete Item at URL (action)
Send E-mail with Document as Attachment (action)

The Workflow will start once a new item is added into the SharePoint list, and it will work in the following manner:

  • Make a copy of the invoice template
  • Fill in the data gathered from the SharePoint List
  • Convert the invoice into a PDF file
  • Send the invoice to the email recipient
  • Save the PDF in the document library

Before creating the Workflow it is necessary to do the following:

  1. Create a template of the invoice. You can download a template example here. We used Content Control elements in such fields as Number, Client, Address, Price, etc.
  2. Save this template in Shared Documents.
  3. Create a document library called “Invoices” where the workflow will save sent invoices.
  4. Create a list with relevant columns along with a column for the client’s email address. This is the address our workflow will send the generated invoice to. The List contains the following fields:

  5. Start SharePoint Designer, open the web-site, point to “Workflows”, click the “List Workflow” button on the ribbon and select the List which you created at step 4. The Workflow will be linked to this List. Enter a name for the Workflow. Click OK. The empty workflow is now created.

Let’s start creating the steps of the Workflow.

To copy the invoice template we should use the Copy or Move Documents action from the Document Library group.

A link to the document template should be specified in the parameters for this activity. The full path to the document should be specified. In our example it is:

http://sp14.vlab.mapilab.local:133/Shared%20Documents/invoice.docx

The new file should be placed in the “Invoices” document library which we created in step 4. It is necessary to specify the full path to the document library. In our example it is: http://sp14.vlab.mapilab.local:133/Invoices/

Set the invoice number field to be used as the data source for the file name:

Next, we should use the Update Word Document action (this action is located in the Office category) to replace “Content Control” values in the document with the values of the corresponding fields of the new item in the document library.

We type in the Content Control name, then specify the name of the document to be updated and the text format. Latest versions of HarePoint Workflow Extensions have additional parameter to specify which occurrences of the content control need to be updated. For this example, you can keep the default option “all occurrences”:

The remaining fields are filled in similarly:

Next, we should add an action to convert the updated document into a PDF file.

To do this, we will use the Convert Document action (this action is located in the Document Conversion category).

The Invoice that was created and completed above is used as the parameter:

Execution of this action will take a while. So, we need to suspend the Workflow until the conversion is finished. For that we will use the Wait Conversion Job action.

After that we will have two invoice files, and the Word document can be deleted by using the Delete Item at URL action from the Lists category. The path to this document should be specified as the parameter:

Now we should add an action to send the generated invoice via email. The Send E-mail with Document as Attachment action from the Email category will be used.

The ‘To’ address is taken from the new element which was added into the List:

Specify the message subject.

And specify the path to the generated PDF invoice.

The workflow is now ready. It looks as follows:

Save the Workflow.

Now we should set the Workflow to be launched automatically when new list item is created. To do this click the “Workflows” link in the left menu of SharePoint Designer, select your Workflow and double click it. Check the option “Start workflow automatically when an item is created” and click the “Save” button on the ribbon.

Save and Publish the Workflow:

Test the Workflow: create a new list item, wait a moment, and look at the Document Library “Invoices”. Check your mailbox, the invoice in PDF should be there. Check the message subject and make sure that all Invoice fields are filled in properly.

You can also watch the video of the whole process of creating this workflow:


Learn more about HarePoint Workflow Extensions and over 350 new actions to automate any business process without programming.

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 3

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

(Visited 2,507 times, 1 visits today)
Share

Leave a Reply

Your email address will not be published. Required fields are marked *