With the fast-changing market, the need for a different type of documents to produce is frequent. The ability to keep pace with the market need is hindered if every time a new document template or update to an existing template requires the business user to reach out to the IT team.
Idea was to provide document generation feature to non PEGA applications/lower than v8.4 PEGA applications of an organization which is already has PEGA Platform license. Reason behind this thought process is, there are many challenges/limitations faced on the document generation functionalities, cost for an additional software for each technology and difficulties in maintaining a huge number of templates in an organization level for several technologies used by certain organization.
What it does
Document generation REST API accepts request as JSON and generate the document along with the merged data from Request JSON and return the merged document (.docx as of now, it can be extended to .pdf also) as Base 64 encoding via JSON response. Requesting application needs to pass the merge fields and the template ID which is already setup through the document generation portal(JSON request automatically generated from user portal for each template).
Each Application or Department or Line of business has an account on document generation portal to setup their templates (Each account will be provided with separate API Key). Business users can deign, map and maintain their templates through the user portal and share the JSON request details for each document to developer and developer needs to map the value from the requesting application and call the document generation REST API.
How I built it
Recent version of PEGA platform v8.4 released with a feature for document generation which can be used for PEGA applications. This document generation REST API built on PEGA v8.4 along with 2 portals to manage accounts and templates which can be used by any application by calling the document generation REST API.(Technology agnostic and easy to setup and maintain)
Admin Portal This is for creating a new account and managing existing accounts. An account could be an application in an organization or a department or a line of business. Once the user is added to an account, the user is notified with the user credentials via email. The ability is also available to make updates to the existing accounts.
User Portal Once the user login to the assigned account, the user could see the account details, such as API Key and REST API Endpoint URL. Users can add new templates to the account then the user should identify the data fields in the template and the data type, whether the type is a scalar or list. User can add fields to template instance on portal and map the same fields accordingly on the template document (.docx file) and upload it. Then test it locally as well as via REST API also through this portal. Once all the tests are successfully completed generated JSON can be shared to developers to integrate the REST API to respective application(s).
Highlights of this solution • Easy to setup and quick turnaround time to go-live • Business users can use this portal as organization/department level master repository for templates. Single place to keep the up to date templates. This will reduce the mismatches between versions compared to conventional approach, having multiple repositories for business users and systems. • Business users can directly update the template in case of a change in format or styling or static text updates. Can simply search and download the template then update and upload it. (if there is no change on merge fields then zero developer effort). • Technology agnostic and most of the platforms support REST API. • In addition to that business users can see the usage of each template on dashboard (Count of each template requests under their account)
Challenges I ran into
Since I'm new to PEGA v8.x (I'm hands on PEGA v7.2.2 and lower versions), I have learned the new features which are introduced above v7.2.2 and applied to this project such as Savable data pages, queue processors, In-built document generation features and new UI design Cosmos within short period of time. It was interesting learning and applying the new features to this project.
Accomplishments that I'm proud of
I'm proud of completing this Hackathon project on-time with great quality(PEGA Compliance score of 97/100) along with my routine work schedule. I will be able to apply this knowledge and new features on my future projects.
What I learned
I have learned the new features of PEGA v8.x and docx4j library functionalities used inside PEGA document generation function used internally.
What's next for DAPI GEN - Document generation via REST API
Currently this document generation API supports return type as Base 64 encoding and .docx as outcome document type. Planning to enhance the return type as
- Uploading the documents to Amazon S3 bucket.
- Sending as email from REST API. In addition to that enhancing the support of outcome document type as .pdf.