top of page
Writer's picturetechpapers

MS Word document generation from Pega

Friends, have you ever come across any requirement where client is asking to generate MS Word Document, which they send to their customer or other businesses. These are well formatted document which has company logo, images , signature and client specific format and fonts. In this blog we will talk about how to generate such formatted MS Word document from Pega.


Below is an example of a document which we will generate in this blog.

The highlighted part in above document is information which Pega added and generate the document.


Lets assume a use case, bank want to dispatch the renewed Credit Card to its customer. Along with renewed credit card a latter will be sent to customer explaining the feature of card. In business terms it is called - Renewal letter. Business has predefined format [ or Word document with their logo, image, signature] which they send to their customer. They want Pega to add few information into this document, like Customer Name, Shipping Address, Card Type etc and generate Word document which can be straight away be printed and sent to customer via Courier.

The document which business gives as input where Pega needs to put some information is called - Template Document


Pega has a smart shape called Generate Document. This smart shape take a MS Word file as input. The input MS Word file is called Template file or input file.





This smart shape looks for some Pega keywords and into template document and replace them with values from Pega Case properties, for example Customer Name , Address or Credit Card Type etc. For example in a document if want to greet customer saying Dear John. Then we need to write a keyword in place of actual name of customer.


Dear <<PegaKeyword>>.


Generate document will replace this keyword with the actual value and generate the document.


Now lets create a template document [ You need to ask this document from your customer in your project] and mark few words which Pega needs to add before sending it to customer. For Pega to identify these words we need to replace them with a keyword.


Lets create a case type called Renewal Credit Card. In this case the first stage we will enter information about Customer , and Credit card. In the next stage we will use Generate document to generate the Renewal document. In Customer Information step, take below input

  • Customer Name

  • Address

  • Courier ID etc.

In Card Information step take below inputs

  • Card Type

  • Card Feature - e.g CHIP & PIN

  • Department Head

In the next stage configure a Document Generate Smart shape. This will generate document and attach it to case.


Click on Generate document shape and in right side panel will show the properties of this shape.

Click on "View and use Fields" button. This will list up all properties of the case. These are the properties you can add into template document. In order to put the value of the properties, you need know the keyword of property. When you click on "View and use Fields" button you will see list of properties and against each property you will see a button called Copy Tag.

Click on Copy tag button to get the keyword for that property and past the same in Template document. Save the document and upload the same in Generate Document property panel. See below image where these keywords are put.


Give title of document and select "File" as category. Save the flow and run the case. Input Customer details.


Click on Submit button and input Card information and click create button.



The next step will replace all keywords with values from the case and generate the document. The document will be attached to the case. If all goes well, then you can download and see the final document .


Optional - you can even store this generated document to AWS repository - see my blog on how to store Pega case attachment to AWS Repository for details steps - https://www.techpapers.online/post/store-pega-case-attachment-files-to-aws-s3-bucket


Environment Information

Pega Version - Pega Personal Edition 8.7


If you have any further query or doubt, you can comment below and we will get back to you . If you find this blog useful then please share this with your team or other developers.





Comments


Post: Blog2_Post
bottom of page