Replacing Bookmarks With Text (Dynamic)Last Updated: 08/23/2018 Introduced in Version: 2.0
This tutorial shows how to replace Bookmarks in a Word Document with desirable Text. The Step that can be used for this function is called a Replace Bookmark With Text (Dynamic) Step. A Word Document invoice template has been created for this example. We have created Bookmarks in this template everywhere that the template has data in square brackets. In this example, we are going to create a Flow with a Form, where the user will be able to enter information, and then, download the Invoice Template using their Information. See the Invoice Word Document below (Figure 1).
Invoice Word Document
Begin the designer folder by creating and naming a Flow. In the Flow designer, navigate to the Steps Tab or use the quick add and locate the Create Data Step from Favorite Steps category in the Quick Add Step dialog (Figure 2). In the Create Data Step under Common Properties and under Data select Show editor to add data definitions.
Add the Data definitions Name and Type. In the drop-down list under Type choose File Data. Next set Doc File under Inputs to Constant and add the Invoice Template Document to the Data Definition (Figure 3).
Next, add a Form to the Flow. In the Steps Tab locate Show Form Step under Favorite Steps and Add or drag and drop the step in the Flow designer. Select Show Form in the Flow designer and then choose Pick or Create to Create and Name the Form (Figure 4). For this example, the Form will be given the name Invoice.
This Form is designed as following, it has numerous Labels and TextBoxes, couple DatePickers, and Submit Button. When we finish designing this Form we can save and close Form Designer (Figure 5).
Next, add Replace Bookmark With Text (Dynamic) Step from the All Steps [Catalog] > Data > Documents category in the Quick Add Step dialog to the flow (Figure 6). Use user inputs on the Form as a Text for the Bookmarks in the Word Document.
Now select Edit Input Mapping Option from this step’s Options. Define the Inputs, bookmark Name, Document File and replace With Text (Figure 7).
In the Mapping Editor, connect DocFile to the documentFile field. Then define bookmarkName field and connect the respective outcome from the Form to the replaceWithText field (Figure 8).
Navigate to Edit Output Mapping, choose Change Value. Then connect Output to the Contents field of the DocFile (Figure 9). This mapping step will update the Contents of our Word Document. Save and close Mapping Editor.
In the Flow designer, add another Replace Bookmark With Text (Dynamic) Step from the All Steps [Catalog] > Data > Documents category in the Quick Add Step dialog (Figure 10).
In the Mapping Editor, map data in a similar manner as the previous step. This time we use another bookmark Step, and therefore, a different output value from the Form (Figure 11).
The Output configuration for this step is exactly the same as for the previous step (Figure 12).
Because we have eleven different bookmarks in the Invoice Template, Eleven Replace Bookmark With Text (Dynamic) steps from the All Steps [Catalog] > Data > Documents category will be used in the flow (Figure 13). The data for each Replace Bookmark With Text will all map in a similar manner using Bookmark Names and User Inputs from the Form. The Output configuration in Mapping Editor is the same for all these steps.
Finally, add another Show Form step from Favorite Steps in the Quick Add Step dialog to create a Download Form. In the resulting window, Name the Form and select Create to proceed to the Form designer.
This Form has a Title, which is a Label component from the Data category, a Button control from Actions category, and a File Download control from File Handling category (Figure 14). When the Form is complete save the Form and close Form designer.
In the Flow designer connect the Outcome from the Download Form to the End Step in the Flow. Select the Edit Input Mapping for the Form step (Figure 15).
In the Mapping Editor, map the updated DocFile to the FileHere Download control on the Form (Figure 16). Then, save and close Mapping Editor.
This completes the Flow design, select Debug Flow on the top action panel of the Flow designer to test the Flow (Figure 17).
The Invoice Form opens in the Debugger. Fill in all required Fields and select Submit (Figure 18).
Next, The Download Invoice Form opens. Select the Download File button (Figure 19).
Next, confirm the Download process. Then Name our File and Save (Figure 20).
Back in the Debugger select Done on the Download Invoice Form (Figure 21).
Locate the New Document file and open it. Confirm that all bookmarks on the Template were changed with user’s inputs (Figure 22).