Maintaining UI State right in Pega with DX API

Maintaining UI State right in Pega with DX API

Introduction

A small introduction if you don’t know pega or DX API. Pega is at the core is a BPM tool for managing work flows and it offers lot more than that. You can learn more at pega.com. DX API is set of REST APIs for accessing Pega’s case management functionalities for building front end in different technologies such as React JS or Angular JS.

The Problem

When using DX API with Pega you will have issues with maintaining the UI states as the DX API is stateless. So the changes you made to the case but not saved is not retained when you do a refresh, unless the data is posted back in each request. So many things works when using Pega natively will not work when using the functionalities through DX API.

An example scenario is setting some values in pre action if you use a data transform to set some values and displaying them in the screen. When loading the screen first time this will work as the UI meta data will be generated after executing the pre actions. But let say there is another on change action in the section where you do a section refresh. This time the values set in the pre action will be lost.

The solution

One way to overcome the issue is always call the pre action rules also in the on change action before performing the actual on-change action. But this will become problematic when you have many on-change actions and everything needs to be called when one thing got changed. So what is the solution?

Hidden fields to the rescue. In the screen add hidden fields to the values set in pre actions and in on change actions. When executing on change refresh action always post the values back (Don’t tick the disable on submit option on refresh) to the server. This way you can manage the UI state effectively without complicating UI actions by calling each actions all the time.

Hope this saved some of your time in your next task. You can ask me other Pega questions or suggest a Pega topic for my next post in the comments below. I am happy to address them. Connect with me on linked at https://www.linkedin.com/in/msnisha/

A full stack developer learning a developing web applications since my university time for more than 20 years now and Pega Certified Lead System Architect (since 2013) with nearly 16 years experience in Pega.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top