You are viewing limited content. For full access, please sign in.

Discussion

Discussion

How to Create Dynamic Document Line Items Using Laserfiche 10

posted on February 24, 2016 Show version history

Article contributed by Alex Wells, Presales Consultant at Laserfiche.

 

Creating line items within a document is an essential component of many business processes. That’s why Laserfiche Workflow has been designed to generate invoices, purchase orders, balance sheets and many other list-formatted documents.

In Laserfiche 9.2 and prior releases, Workflow’s “Fill out PDF Form” activity was used to generate documents with line items, but the activity was limited by the number of line items in a fillable PDF.

In Laserfiche 10, Workflow is equipped with an “Update Word Document” activity that enables users to automatically generate dynamic line-item documents in a Microsoft Word document.

This article will focus on creating an invoice template in Microsoft Word and using the “Update Word Document” activity to process merge fields and dynamically insert line items.

 

Adding Merge Fields

 

Merge fields are used as placeholders for invoice information and can be added to a Word document by:

  • Clicking the “Insert” tab
  • Selecting “Quick Parts” from the Text section
  • Clicking the “Field” option

  • Selecting “MergeField” from the list of field names in the field dialog box and filling in the field name under the Field Properties section
  • Leaving the other MergeField options at their default values

 

In the Field dialogue box, select “MergeField” from the list of field names, and fill in the field name under the Field Properties section:

After clicking “OK,” a merge field will be placed in the Word document where the cursor is located. These fields will be used as placeholders for Workflow to fill with information.

Creating an Invoice Template

Now that the instructions on how to use merge fields have been covered, here is how to create an invoice template in Microsoft Word.

Each page of the invoice should have identifying information about the document. For instance, a user may want the following items at the top of every page (see the image below for an example):

  • Company logo
  • Document type
  • The customer’s billing address
  • The invoice number and column headers

 

This invoice includes a company logo, document type, customer billing address, invoice number and column headers.

The following steps allow users to create an invoice header with these parameters:

  • Place merge fields in the appropriate areas for first name, last name, address and invoice number.

  • Add a table row in the body of the document, which will be repeated for every line item.
  • Fill each column with a merge field that corresponds to item number, description and all other relevant parameters. Users only need to create one table row, as Workflow will target this table and add rows for multiple line items as needed.

This table must be named so that Workflow can find it in the Word document. In this example, it will be named “MyTable” by adding the following merge fields:

  • In the far-left cell of this row, insert a merge field to the left of the item number field, and name it “TableStart:MyTable.” This denotes the beginning of the table’s row.
  • In the far-right cell, insert a merge field named “TableEnd:MyTable” to the right of the line total field. This denotes the end of the row.
  • These two fields are marked with arrows in the picture below.
  • Below the table row, add the subtotal, tax rate, tax and total fields. Then add their corresponding merge fields.

Designing the Workflow

Now that the invoice template is complete, a workflow can be designed to fill in each merge fields area with the appropriate values.

The image below shows an example of a workflow that finds an invoice’s information, enters the information into the invoice template and emails the newly generated invoice file.

  • The “Query Data” activity finds all of the information relevant to the invoice, including the customer’s information and all of the line-item values.
  • The “Update Word Document” activity fills out the Word invoice template.
  • The “Email” activity emails the completed invoice to the appropriate party.

 

Configuring the “Update Word Document” Activity

In the properties pane, choose “Server Attachment” as the source. Server attachments are electronic documents attached to the current Workflow server and are available to any Workflow designer using the same server. For more information on attaching files to a workflow server, click here.

Next, tell the activity what merge fields to look for and what values to replace them with.

  • Click the “New…” button, and select the “Simple Field Merge” type. This type is for replacing a merge field with a single-value token from Workflow.
  • Click “Import Field Names from Document” and assign the Word template’s tokens to each merge field that is NOT in “MyTable.”

  • Since there might be an empty “Address Line 2″ value, check the “Remove empty paragraphs” and “Remove unused fields” boxes so that the invoice won’t show an empty space.

 

For the line items, a different modification type is required. In the “Update Word Document” activity’s Properties pane, click “New…” again and select “Table Field Merge” from the type drop-down list. This setting is used when the user wants a Mail Merge region to expand based on the number of values in a multi-value token. For instance, if the “Query Data” activity returns twenty values, then the region named “MyTable” would expand to fit all twenty values.

  • Click “Select…” under Source Data File, and choose the line-item values that were retrieved with the “Query Data” activity
  • The “Merge Region Name” is “MyTable,” the name of the line-item table in the Invoice template.
  • Click “Import field names from document…”, and assign the “Query Data” tokens to each MergeField inside the “MyTable” rows.

Convert the resulting Word document to a PDF file by clicking the advanced properties of the “Update Word Document” activity and checking the “Convert to PDF” box. Users can see how the document turned out by attaching the resulting file to an email.

Laserfiche 10 includes many new features and enhancements that allow users to work in the repository with greater ease and efficiency. Workflow’s “Update Word Document” activity is a powerful tool for generating dynamic content, including line-item documents, personalized letters, agendas, permits or forms. With the use of Mail Merge formatting, Laserfiche users can generate any document type that can be made using token substitutions.

Readers are encouraged to comment on this post with any questions or comments about this topic.

12 0
replied on February 13

Is it possible to dynamically create table columns as well (only a single row)? For example:

Field1     Field2     Field3     Field4
Value1    Value2    Value3   Value4


The use case in which this would be useful is if not all of the fields have a value. So, in some instances, I may have 10 values to display (column heading + value) and at other times, I may only need to display 4 columns and their values. In my current solution, I have to setup a placeholder for each column and each value. If values are not present, I've reserved a lot of the page and I'm displaying extra columns adding no value to the report. In essence, it's similar to the multi lined invoice or PO example, except I'm writing columns instead of rows. 

Thank you! 

0 0
replied on January 5

Hi Joanna,

 

   Thanks for the great information. I've implemented this in a workflow and have successfully been able to updated documents and then email them as PDFs. I've a quick followup question. How do I then automatically save the generated PDFs to the repository as new documents? I tried using the Create Entry tool, but can't seem to figure out how to grab the UpdateWordDocument_Result file.

 

Thanks,

Michael

You are not allowed to follow up in this post.

Sign in to reply to this post.