{"id":255,"date":"2011-11-25T15:10:12","date_gmt":"2011-11-25T15:10:12","guid":{"rendered":"https:\/\/www.harepoint.com\/Blog\/?p=255"},"modified":"2022-07-21T13:42:34","modified_gmt":"2022-07-21T13:42:34","slug":"sharepoint-workflow-pdf-conversion","status":"publish","type":"post","link":"https:\/\/www.harepoint.com\/Blog\/sharepoint-workflow-pdf-conversion\/","title":{"rendered":"Generation of the invoice. PDF Conversion with SharePoint workflow."},"content":{"rendered":"\n<p>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 <a href=\"\/Products\/HarePointWorkflowExtensions\/Default.aspx\">HarePoint Workflow Extensions for SharePoint<\/a>:<\/p>\n<table style=\"border: 1px solid black;\">\n\t<tbody>\n\t\t<tr>\n\t\t\t<td rowspan=\"2\" style=\"border: 1px solid black;\"><b>Component name and type<\/b><\/td>\n\t\t\t<td style=\"text-align: center; font-weight: bold;\" colspan=\"2\">Set of Workflow components<\/td>\n\t\t<\/tr>\n\t\t<tr>\n\t\t\t<td style=\"text-align: center; font-weight: bold; border: 1px solid black;\">SharePoint Workflow<\/td>\n\t\t\t<td style=\"text-align: center; font-weight: bold;\"><a href=\"\/Products\/HarePointWorkflowExtensions\/Default.aspx\">HarePoint Workflow Extensions<\/a><\/td>\n\t\t<\/tr>\n\t\t<tr>\n\t\t\t<td>Copy or Move Documents (action)<\/td>\n\t\t\t<td style=\"border: 1px solid black;\"><\/td>\n\t\t\t<td style=\"text-align: center;\"><img decoding=\"async\" src=\"\/Pictures\/Workflow\/yes.gif\"><\/td>\n\t\t<\/tr>\n\t\t<tr>\n\t\t\t<td>Update Word Document (action)<\/td>\n\t\t\t<td style=\"border: 1px solid black;\"><\/td>\n\t\t\t<td style=\"text-align: center;\"><img decoding=\"async\" src=\"\/Pictures\/Workflow\/yes.gif\"><\/td>\n\t\t<\/tr>\n\t\t<tr>\n\t\t\t<td>Convert Document (action)<\/td>\n\t\t\t<td style=\"border: 1px solid black;\"><\/td>\n\t\t\t<td style=\"text-align: center;\"><img decoding=\"async\" src=\"\/Pictures\/Workflow\/yes.gif\"><\/td>\n\t\t<\/tr>\n\t\t<tr>\n\t\t\t<td>Wait Conversion Job (action)<\/td>\n\t\t\t<td style=\"border: 1px solid black;\"><\/td>\n\t\t\t<td style=\"text-align: center;\"><img decoding=\"async\" src=\"\/Pictures\/Workflow\/yes.gif\"><\/td>\n\t\t<\/tr>\n\t\t<tr>\n\t\t\t<td>Delete Item at URL (action)<\/td>\n\t\t\t<td style=\"border: 1px solid black;\"><\/td>\n\t\t\t<td style=\"text-align: center;\"><img decoding=\"async\" src=\"\/Pictures\/Workflow\/yes.gif\"><\/td>\n\t\t<\/tr>\n\t\t<tr>\n\t\t\t<td>Send E-mail with Document as Attachment (action)<\/td>\n\t\t\t<td style=\"border: 1px solid black;\"><\/td>\n\t\t\t<td style=\"text-align: center;\"><img decoding=\"async\" src=\"\/Pictures\/Workflow\/yes.gif\"><\/td>\n\t\t<\/tr>\n\t<\/tbody>\n<\/table>\n<p>The Workflow will start once a new item is added into the SharePoint list, and it will work in the following manner:<\/p>\n<ul>\n\t<li>Make a copy of the invoice template<\/li>\n\t<li>Fill in the data gathered from the SharePoint List<\/li>\n\t<li>Convert the invoice into a PDF file<\/li>\n\t<li>Send the invoice to the email recipient<\/li>\n\t<li>Save the PDF in the document library<\/li>\n<\/ul>\n<p>Before creating the Workflow it is necessary to do the following:<\/p>\n<ol>\n\t<li>Create a template of the invoice. You can download a template example <a href=\"\/Products\/HarePointWorkflowExtensions\/invoice.zip\" onclick=\"targetProductDownload('invoice', '\/Products\/HarePointWorkflowExtensions\/invoice.zip', false);\">here<\/a>. We used Content Control elements in such fields as Number, Client, Address, Price, etc.<\/li>\n\t<li>Save this template in Shared Documents.<\/li>\n\t<li>Create a document library called \u201cInvoices\u201d where the workflow will save sent invoices.<\/li>\n\t<li>\n\t\tCreate a list with relevant columns along with a column for the client&#8217;s email address. This is the address our workflow will send the generated invoice to. The List contains the following fields: \n\t\t<p><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-invoices-01.png\"><\/p>\n\t<\/li>\n\t<li>Start SharePoint Designer, open the web-site, point to \u201cWorkflows\u201d, click the \u201cList Workflow\u201d 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.<\/li>\n<\/ol>\n<p>Let&#8217;s start creating the steps of the Workflow.<\/p>\n<p>To copy the invoice template we should use the <b>Copy or Move Documents<\/b> action from the <a href=\"\/Products\/HarePointWorkflowExtensions\/Document-Library-SharePoint-Workflow-Action.aspx\">Document Library<\/a> group.<\/p>\n<p><a href=\"\/Pictures\/Workflow\/example-invoices-02.png\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-invoices-02.png\"><\/a><\/p>\n<p>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:<\/p>\n<p><i>http:\/\/sp14.vlab.mapilab.local:133\/Shared%20Documents\/invoice.docx<\/i><\/p>\n<p>The new file should be placed in the \u201cInvoices\u201d 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: <i>http:\/\/sp14.vlab.mapilab.local:133\/Invoices\/<\/i><\/p>\n<p>Set the invoice number field to be used as the data source for the file name:<\/p>\n<p><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-invoices-03.png\"><\/p>\n<p>Next, we should use the <b>Update Word Document<\/b> action (this action is located in the <a href=\"\/Products\/HarePointWorkflowExtensions\/Office-SharePoint-Workflow-Action.aspx\">Office<\/a> category) to replace \u201cContent Control\u201d values in the document with the values of the corresponding fields of the new item in the document library.<\/p>\n<p><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-invoices-04.png\"><\/p>\n<p>We type in the Content Control name, then specify the name of the document to be updated and the text format. Latest versions of <a href=\"\/Products\/HarePointWorkflowExtensions\/Default.aspx\">HarePoint Workflow Extensions<\/a> have additional parameter to specify which occurrences of the content control need to be updated. For this example, you can keep the default option \u201call occurrences\u201d:<\/p>\n<p><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-invoices-05.png\"><\/p>\n<p>The remaining fields are filled in similarly:<\/p>\n<p><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-invoices-06.png\"><\/p>\n<p>Next, we should add an action to convert the updated document into a PDF file.<\/p>\n<p>To do this, we will use the <b>Convert Document<\/b> action (this action is located in the <a href=\"\/Products\/HarePointWorkflowExtensions\/Document-Conversion-SharePoint-Workflow-Action.aspx\">Document Conversion<\/a> category).<\/p>\n<p>The Invoice that was created and completed above is used as the parameter:<\/p>\n<p><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-invoices-07.png\"><\/p>\n<p>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 <b>Wait Conversion Job<\/b> action.<\/p>\n<p><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-invoices-08.png\"><\/p>\n<p>After that we will have two invoice files, and the Word document can be deleted by using the <b>Delete Item at URL<\/b> action from the <a href=\"\/Products\/HarePointWorkflowExtensions\/Lists-SharePoint-Workflow-Action.aspx\">Lists<\/a> category. The path to this document should be specified as the parameter:<\/p>\n<p><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-invoices-09.png\"><\/p>\n<p>Now we should add an action to send the generated invoice via email. The <b>Send E-mail with Document as Attachment<\/b> action from the <a href=\"\/Products\/HarePointWorkflowExtensions\/E-Mail-SharePoint-Workflow-Action.aspx\">Email<\/a> category will be used.<\/p>\n<p>The &#8216;To&#8217; address is taken from the new element which was added into the List:<\/p>\n<p><a href=\"\/Pictures\/Workflow\/example-invoices-10.png\" data-rel=\"lightbox-image-1\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-invoices-10.png\"><\/a><\/p>\n<p>Specify the message subject.<\/p>\n<p><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-invoices-13.png\"><\/p>\n<p>And specify the path to the generated PDF invoice.<\/p>\n<p>The workflow is now ready. It looks as follows:<\/p>\n<p><a href=\"\/Pictures\/Workflow\/example-invoices-11.png\" data-rel=\"lightbox-image-2\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-invoices-11.png\"><\/a><\/p>\n<p>Save the Workflow.<\/p>\n<p>Now we should set the Workflow to be launched automatically when new list item is created. To do this click the \u201cWorkflows\u201d link in the left menu of SharePoint Designer, select your Workflow and double click it. Check the option \u201cStart workflow automatically when an item is created\u201d and click the \u201cSave\u201d button on the ribbon.<\/p>\n<p>Save and Publish the Workflow:<\/p>\n<p><img decoding=\"async\" src=\"\/Pictures\/Workflow\/example-invoices-12.png\"><\/p>\n<p>Test the Workflow: create a new list item, wait a moment, and look at the Document Library \u201cInvoices\u201d. 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.<\/p>\n<p>You can also watch the video of the whole process of creating this workflow:<\/p>\n<iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/lH-QgL-FoJ0\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<hr><p>Learn more about <a href=\"\/Products\/HarePointWorkflowExtensions\/Default.aspx\">HarePoint Workflow Extensions<\/a> and over 350 new actions to automate any business process without programming.\n","protected":false},"excerpt":{"rendered":"<p>This article describes how to create SharePoint Workflow which automatically generates and sends invoices to e-mail recipients. The invoice will be generated and sent as soon as a new item is added into the list.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[12,19,11,25],"_links":{"self":[{"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/posts\/255"}],"collection":[{"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/comments?post=255"}],"version-history":[{"count":13,"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/posts\/255\/revisions"}],"predecessor-version":[{"id":2860,"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/posts\/255\/revisions\/2860"}],"wp:attachment":[{"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/media?parent=255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/categories?post=255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.harepoint.com\/Blog\/wp-json\/wp\/v2\/tags?post=255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}