Close popover

Table of Contents

How to use Word Template-based correspondence generation

Summary

If you are using a Microsoft Word template in your application, you can include property references along with text and graphics in the template. Using a standard flow action rule, you can merge the properties into the template and include it as correspondence in your application. This article describes how to merge the properties into a Word template and include it in your application flow.

Microsoft Word 2007 was used for the procedure and examples in the article.

For information about configuring Word merge operations in Pega® 7.2.2, see Providing Word merge operations. If you are using another version of Pega Platform, see the online help.

Suggested Approach

The procedure to merge property values into a Word template has five parts:

  1. Configure Windows document settings.
  2. Create the Word Template rule and Word template.
  3. Create the flow action rule.
  4. Update the flow for your application.
  5. Test the merged document.

Configuring Windows document settings

  1. Open My Computer.
  2. Choose Tools > Folder Options > Files Types.
  3. Select the filetype DOC.
  4. Click Advanced.
  5. In the Edit File Type window, disable Confirm open after download.
  6. Enable Browse in the same window.
    zzz
  7. Click OK.

Creating the Word Template rule and Word template

  1. In Process Commander, create a new Word Template rule. Word Template rules are in the SysAdmin category.
  2. In the Purpose field, enter the Word template name. In the example, the template name is OrderConfirmation.
  3. Select your RuleSet name and version from the dropdown list.
    zzz
  4. Click Createand the Word Template rule form opens.

    zzz

  5. Click Edit Word Template to create the Word template.
  6. Enter the text and graphics that you want to be standard in the template.
  7. Click on the Word icon in the upper left corner, then click Word Options.
  8. Click Advancedand, in the Show Document Content section, enable Show field codes instead of their values.

    zzz

  9. Click OK.
  10. Position your cursor on your template where you want to insert a Process Commander property.
  11. Choose Insert > Quick Parts > Field > Field Codes to insert the field code, then click OK. This inserts a field code placeholder in the template.
    zzz
  12. Repeat for each property. In the example, the fields are placeholders and must be modified to reference Process Commander properties.
    zzz
  13. Edit the field codes using the following syntax to reference Process Commander properties:
    { pega:reference .Process Commander property }. Note that the reference to a property is dot qualified. In the example, the field codes reference pyID, OrderTotal, and pyCompany properties.zzz
  14. Repeat the procedure for all field codes in your template. You can switch between displaying field codes and values in your document by pressing ALT+F9.
  15. Save the Word template and close Word.
  16. Click the Save toolbar button to save the Word Template rule.

Creating the flow action rule

  1. Open the standard flow action rule Pegasample.CreateMergedWordDoc.
  2. Click the Save As toolbar button.
  3. In the Applies To field, select the class name for your application from the SmartPrompt list.
  4. Select your ruleset name and version from the dropdown list.
  5. Click Save As.
  6. Change the short description to be relevant to the document and the action that the user performs. In the example, the short description is Create Confirmation Letter.
  7. Open the Action tab.
  8. In the Before This Action section TemplateName field, enter the name of your Word template rule. Note that this text must be in quotes.
  9. In the After This Action section pyNote field, enter the value that you want to display in the Description column of the attachment window.
  10. In the After This Action section pyCategory parameter, enter the attachment category to which the Word document will be saved.

    zzz

  11. Click the Save toolbar .
  12. Open the standard activity rule, Pegasample.SetMergeActionParams.
  13. Click the Save As toolbar button.
  14. In the Applies To field, select the class name for your application from the SmartPrompt list.
  15. Do not change the Activity Name field.
  16. Select your RuleSet name and version from the dropdown list.
  17. Click Save As.
  18. Open the Security tab and clear the Privilege Class field.
  19. Click the Save icon.

Updating your application flow

  1. Open the flow rule to which you want to add the Word merge feature.
  2. Click the Flow Editor icon.
  3. Add an assignment shape to the flow to perform the Word merge.
  4. Add a connector to the assignment shape that calls the flow action rule CreateMergedWordDoc.
    zzz
  5. Click the Save toolbar button.

Testing the merged template

  1. Click the Run toolbar button.
  2. Step through the application until you reach the assignment to create a confirmation letter. The form will have an action named, Create Confirmation Letter, and a button on the left labeled, Create Merged Document.zzz
  3. Click Create Merged Document to display the document with the property values included.
    zzz
  4. Submit the purchase order, then click the Attachments icon to view the attached Word document.
    zzz


66% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.