Generating a Microsoft Word Contract from Laserfiche Forms Data
Updated: Nov 27, 2019
It is well known that Laserfiche Forms is typically used to capture data and other information directly from users. But, many of our clients have extended the functionality of Laserfiche Forms by leveraging Laserfiche Workflow to accomplish many things Forms cannot provide on its own. One of these extended capabilities is the insertion of information into a MS Word document. To accomplish this, users continue to use Forms to capture contract details like the parties involved, dates, and amounts. Then, with the help of workflow, have those contract details automatically inserted into a Word document for review and printing.
In this month’s article, CDI’s Software Trainer, Kyle Knebel, will walk us through how to accomplish the insertion of information into a Word document. In this example, we’ll fill out a Contract document. The instructions below are broken up into three main steps:
Step 1: Create your MS Word contract document
Step 2: Creating the Laserfiche Contract e-Form and Business Process
Step 3: Creating the Workflow to Generate the MS Word Contract document
Step 1: Create your MS Word contract document.
a. Get your contract document setup in MS Word; along with the Replacement Token text that will be replaced by the information coming from the Form.
Replacement Token Text examples:
Company Name = 1CompanyName1
Contract Effective Date = 2EffectiveDate2
Expiration Date = 3ExpirationDate3
*We will later use the Find-Replace function to replace the replacement token text with the actual data and dates.
b. Save the new MS Word document to a windows folder. Later, you will upload this document as a Master Document within the Update Word Document Workflow activity.
Step 2: Creating the Laserfiche Contract e-Form and Business Process
Next, you’ll want to build your Laserfiche Forms Business Process, which really is a pretty simple design. You gather some information on the e-form, and then upon submission, the data is used by Laserfiche Workflow to create the filled-out MS Word Contract.
Open Laserfiche Forms and click on the Manage tab.
a. Create a New Business process in Laserfiche Forms Designer (you can create one from scratch or pick a pre-built template)
We’ll create a Blank process for this example. Give the process a name and then press Create.
b. Once in the Design screen, skip down to the Forms section and create a new form. Click on the Create New Form link and give it a name, for example, Contract Submission Form.
c. Insert a Single Line Field for the Company name, insert date fields for the Effective Date and Expiration date fields.
d. Go to the Process Diagram section in the Process Designer.
e. Configure the process steps to send the Contract metadata to Laserfiche Workflow.
1. Drag the Start Message activity to the canvas and release.
2. Open the details pane of the Message Start Event on the right side of the screen.
3. Set the starting form (there should only be one)
4. Next, drag the Workflow Service Task activity to the canvas
5. Click on the green Message Start Event so that you see the connection arrow above it.
6. Connect the activities with an arrow from the green start event linked to the Workflow task. Click and drag the arrow over to one of the Service task’s connection points and release onto one of the points.
7. Click on the Service task icon and open the details pane, then enter the Workflow Name. Let’s call it Contract – MS Word.
*Note: The workflow has yet to be built, but we will name it here in this step, and use the same name when we build the workflow.
8. Drag the End Event activity to the canvas.
9. Connect the Service Task to the End Event.
f. As you can see, the Business Process is very simple, with just three steps. We can now move on to the Laserfiche Workflow Designer.
g. Navigate to the Settings>Access Rights section and assign the users who will be using this form, and then go to the Settings>Process Options to publish the workflow.
Step 3: Creating the Workflow to Generate the MS Word Contract document.
a. Launch the Laserfiche Workflow Designer windows application.
b. Name the new workflow as you named it in the Forms Service Task and connect it to the local Laserfiche Repository using the Manage workflow connection profiles.. link.
c. Build the workflow activities that will fill out the MS Word Contract.
1. Drag the Retrieve Business Process Variables activity to the workflow canvas.
2. Set the properties on the activity to connect to the Forms server, set the Form and select the field values to retrieve.
3. Next, add the Update Word Document activity
4. Configure the properties of the activity by uploading the Contract document you just edited (the one with the replaceable text). Press the ellipsis button to select the Word file attachment.
5. Press the Add button, press the ellipsis button and select your Word file. Click OK, then press Close.
6. Next, modify the activity so that it runs the Find-Replace function that updates the values for the contract.
i. Press New…
ii. For the first field, enter the Find what: value as the replaceable text, which in our example is 1CompanyName1.
a. Check Match case and Match whole word and enter the token for Replace with: value.
b. Select the token and click OK.
In our example, we will have three Find Replace modifications.
7. Repeat the modifications by adding the other replacement fields.
8. When the Update Word Document activity runs, by default, it creates a new document from the source document it used as a template.
To access this document, you will need to pair the Update Word Document activity with an Email or Attach Electronic Document activity.
To store the Contract as a document in the repository, you’ll use both the Create Entry activity and the Attach Electronic Document activity.
i. Drag the Create Entry activity onto the canvas, after/under the Update Word Document activity.
ii. Set the properties of the activity…
iii. Then add the Attach Electronic Document activity.
Set the properties on the activity. Choose Activity as your Source…
Set the Update Word Document>Result File as the source…
Set the Attach File To as Other Entry and select Create Entry>Output Entry…
d. Publish the new workflow, which will not require any conditions nor a schedule. It should Validate without errors, but if you get any warnings or errors, correct the issue and then republish.
Validation will run and then you can press No when asked if you want to create start rules. Since the Forms process starts the workflow, there is no need to give Workflow any start rules for this workflow.
Thanks, Kyle! Now that readers have had a chance to practice and complete all three steps, it’s now time to create some contracts by filling out a Form. If you have any questions or wish to speak with a CDI professional team member, contact us at firstname.lastname@example.org.