Description:
Replace the Word document with variables & globals
Inputs
- templateName – Choose the desired Report Template
- outputFileName - Name of the output file
- varName - Variable/Global to hold the output file path
Returns
- True – step executed successfully
- False – step failed to execute
Usage:
![](https://static.helpjuice.com/helpjuice_production/uploads/upload/image/8802/direct/1715691489790-image.png)
Example:
Let’s build and execute the wordDocReplacerDef example.
- Create a new definition called “wordDocReplacerDef”
- Select the definition and click the “design” button
- Drag an “updateVariablesWithSQL” and “wordDocReplacer” and connect with the Start step
- Connect the dots between the steps as shown in the Usage above
- Define a few variables/globals to store the SQL fetch result and Output document file path after execution
![](https://static.helpjuice.com/helpjuice_production/uploads/upload/image/8802/direct/1715686140945-image.png)
- Click the "updateVariablesWithSQL" step to configure its "Settings" properties. Give the step a name. Select the Connection String from the drop-down list. In the text area, provide the SQL Select statement. Click the button to assign the SQL column values to the process variables/globals.
![](https://static.helpjuice.com/helpjuice_production/uploads/upload/image/8802/direct/1715687389142-image.png)
- A popup window is displayed for configuration. Click on the Add Row button to insert a blank row. As shown below, provide the SQL column names and map them to the process variables/globals. Click on the Save button to confirm the configuration.
- Open Microsoft Word and prepare a DOCX template file, as shown below. The template file includes the process variables/globals, which are replaced with actual values when the document is created during the process instance. Provide a name and save the template DOCX file in your local folder.
![](https://static.helpjuice.com/helpjuice_production/uploads/upload/image/8802/direct/1715687585617-image.png)
- Click on the "wordDocReplacer" step to configure its "Settings" properties. Give the step a name. Click on the file icon and upload the DOCX report template file. Provide the variable/global to store the output file path.
![](https://static.helpjuice.com/helpjuice_production/uploads/upload/image/8802/direct/1715687815002-image.png)
- Click on the "wordDocReplacer" step to configure its "Advanced" properties. Provide a name for the output DOCX file. Click on the Save button to confirm the configuration.
![](https://static.helpjuice.com/helpjuice_production/uploads/upload/image/8802/direct/1715687921593-image.png)
- Save the process definition, create a new process instance, and execute. The process instance is completed without any human intervention.
![](https://static.helpjuice.com/helpjuice_production/uploads/upload/image/8802/direct/1715688637750-image.png)
- Render the process instance. Click on the “wordDocReplacer” process step to view the properties.
![](https://static.helpjuice.com/helpjuice_production/uploads/upload/image/8802/direct/1715688751606-image.png)
- The step should generate a DOCX file using the variables/global values provided during the run time. The output variable holds the file name path, as shown below.
![](https://static.helpjuice.com/helpjuice_production/uploads/upload/image/8802/direct/1715688529382-image.png)
- Navigate to the Status—File Manager—OutputDocs folder. Right-click the DOC file to search and download it.
![](https://static.helpjuice.com/helpjuice_production/uploads/upload/image/8802/direct/1715688962272-image.png)
- The word document is replaced with the variable values during the process instance.
![](https://static.helpjuice.com/helpjuice_production/uploads/upload/image/8802/direct/1715688907778-image.png)