Savable Data Pages in Pega
In this blog article, we will see about the configuration and usage of savable data pages.
This tutorial was implemented using Pega personal edition 8.5
For some basics about data pages, you can visit my other blog article on data pages –
When we think about data pages, the first thing that comes to our mind is – to retrieve data from any system. By using the scope, refresh strategy configurations, we can maximize the use of data pages in our business processing.
What is a savable data page?
With the Pega 7.4 version, Pega introduced a new data page mode of type – Savable (so now totally 3 – Read-only, Editable and Savable)
Business requirement: Say, a banking organization – ABC, uses pega application to service the customers. Pega application is configured to use two different data types to save the customer details and their corresponding loan details. During call with the customers, the bank employees need to retrieve the customer and loan details in the customer service portal and they may need to update those values if required.
Now how can we achieve this requirement?
– Since customer and loan details are stored in data type, we can use data pages to retrieve the right customer details.
– We can populate the details in a Pega section, the loan details in a repeating grid.
– End users should be able to edit the data.
– In the post activity of the flow action, we can use some activity to copy the data into a page and do obj-save.
But…. use this solution, If your application is still using Pega 7.3 or lesser versions!!
With Pega 7.4 and greater versions, you can use Savable data pages to achieve this!
From the above picture, you can see that using Savable data page, all the processing options to save are configured in the data page itself.
This is one of the main advantages of using a savable data page, that all the configurations stay within the data page rule and thus improve the maintainability.
What are the pre-requisites for this tutorial?
As a pre-requisite for this tutorial, I configured two data types – Customer details and Loan details.
During data type source configuration, you get an option to create data pages. I used that option and Pega created totally three data pages out of which one is Savable data page.
Open the savable data page to look into the configuration.
Optionally, you can also create a new data page and follow the tutorial.
What are the configurations in a Savable data page?
You will see the following basic configurations on a savable data page.
Data page definition
a) Data page mode – Savable
b) Scope – It can be either thread or requestor level but not node level.
Important note: Node level scope is applicable only for read only data pages. It is not applicable for editable or savable data pages.
c) Refresh strategy is not applicable
d) No change/difference on Data sources and post loan processing block
e) You will find an additional block for data save options
Save type
We know the data source dropdown varies based on data page structure – Single page or List, similarly Save type dropdown varies based on page structure.
Here, my data page structure is of type – Page
For Page structure, you see there are 5 options.
Note: For Page list structure, you will find 4 options except database save.
Database save and Activity are the two main options, we may use frequently. First, let’s look briefly into other options
Connector – You can use connect REST to make an update to the external system. PUT, POST or PATCH methods to make an update to other systems.
Robotic automation & Robotic desktop automation – You can use the robotic automation and robotic desktop automation processes to make updates.
Database save –
This is applicable only for Page structure. So obviously this option is used to save a single page (single data instance).
Class name – In the class name, you can select the instance class which we need to save.
You may get a question, we already specified the data page class, then why we need to specify the class again?
This option provides flexibility that you can also map the data page data into another class and save the different class instance.
When you want to save the data into another class instance, obviously you need to map the data right? –
Data transform – This will be mandatory when you select a different class because mapping is mandatory. If it is the same class, you can optionally use the data transform for further processing.
Validate rule – We also have an option to validate certain fields before making the save. System will throw error, if the validation fails.
Activity save –
Though this option is applicable for both page and list structure, you will use it mostly for only list data pages and Pega pre-selects this option when our data page is of type list.
You can provide the activity name here. We will see about this option little later.
On all the data save options, you will find a checkbox – Local save.
Local save – The value on this checkbox does not affect/influence the data save processing. It is mainly used for reporting and auditing purposes only.
Select this option if you are saving the instance into local pega database.
You can find the Local save checkbox usage in the following link –
Add save option link – You will see there is an Add save option link to add multiple save options. So we have the flexibility to add multiple save options and use the WHEN rule to determine which save option to use.
First, let’s start with configuring the database save option.
Now the question is, how the data save will be triggered? Will the save option be performed automatically whenever we refer to the data page? – The answer is NO. Referring to data pages is just going to load your data page. Every time you need to explicitly save the data page if you want to save the instance.
What are the options to explicitly use/trigger the savable data pages?
1. In the flow rules – advance shape – Save data page
During flow processing, you can add this smart shape and specify the savable data page name.
2. In the flow action rules – action tab post processing
Your flow action, may be used to display and/or edit the customer details. Here you can use Savable data page, to load the customer details and present in the user screen for edit. Once the user edits the customer details and clicks submit, In the post-processing of the flow action, you can use the savable data pages to save the data instances
You can also add multiple data pages and use the WHEN condition to conditionally save the data page.
Also if any property refers to the savable data page, then you can use the associated property checkbox and refer to the property name instead of data page.
Important note: The order of post-processing will be savable data page execution, followed by data transform and activity.
3. Activity method – Save-DataPage method
Similar to flow action configuration, you can use associated property reference or directly refer the data page.
You see an additional parameter – WriteNow.
It is time to talk about the commit operation on the data save.
We know that in Obj-save steps, we have an option of WriteNow which can either commit the save directly (Independently) into the database or save it into da eferred save list, so it gets committed to the database in the next chain transaction.
Exact similar concept, Savable data pages also can be committed independently or deferred
WriteNow = true – The save to database occurs immediately as a separate transaction
WriteNow = false – The save is deferred and get committed in the next transaction.
Do you wonder why this option is not available in flow & flow action?? – Usually, flow processing takes care of the commit transaction at the right time so the flow action and flow rule smart shape always pass the WriteNow as false (under the hood) and is always deferred and get committed into the chain transaction.
In this tutorial, I am going to use the Activity to showcase the triggering of Savable data pages.
Let’s get our hands dirty.
Tutorial to trigger the Savable data page using activity
I am going to use the already created savable data page of the Customer details data type.
Step 1: Set up the right data in your data type.
In the customer details data type, I just made an entry with the primary key Customer ID = C-12345
In the activity, I will update the phone number. Just think it similar to the UI screen where I can update the phone number and trigger the Savable data pages in the post-processing.
Step 2: Create a test activity and load the data page with the right parameter.
Use property-set method and update the phone number.
So the step page loads the data page with the current data and I update the phone number.
Step 3: Add a step – Save-DataPage – This is going to trigger the data save option.
Remember, Savable data pages never get saved automatically. If you don’t use this step, then nothing is going to happen!
For now, WriteNow is unchecked.
Step 4: Start the tracer and run the activity manually.
You will see the activity method invokes OOTB generic activity – pxUpdateRecord
Note: This is used for updating rule or data instance.
You also see the activity parameter – WriteNow getting used.
Since we pass it as false, it is going to stay false and hence the changes will not committed unless your processing faces an explicit commit.
Step 5: Verify the data instance in the data type
It will not be updated.
Step 6: Now, check the WriteNow parameter in the Save-datapage method and run the activity.
In the tracer, you will find the commit operation also in the parameters you will see that WriteNow is true.
Step 7: Verify in the data type, the value should be updated.
Important note: Use the WriteNow option only when necessary. You may need to maintain the data in a chain transaction and hence deferred save can be preferred and in case of error, the operation can always be rolled back. Choose what suits you best in your application.
Till now we talked about the Database save option by saving a single instance.
Now what if your data page is of type – List, then you need to use an activity as a data save option?
Tip: Going forward, we will refer two activity types. One as Trigger/invoking activity which use the Save-DataPage method to trigger the data save and the other as Data save activity that will be configured inside the data page rule. Just don’t confuse it 🙂
Step 1: Create a new data page of type list – savable under Loan Details class.
I just did a save-as of the D_LoanDetailsList (auto-created from data type) into savable data page.
So for the source block, I use the default data table editor report to load the loan details list.
Step 2: In the save type drop-down, select Activity.
Step 3: Configure the data save activity.
Create a new activity – SaveLoanDetails of class Code-Pega-List.
Important note: You cannot directly save on the data page pxResults<i>. You should copy into some other page and then do the save.
Add a Obj-Save method.
For now, I am NOT using any Write Now option in Obj-Save method.
Important note: NEVER use commit method directly in the data save activity, because this may break the transaction which may result in undesired output.
Now our activity is ready.
Step 4: Configure the activity in the data save option.
Save the data page rule.
Step 5: Set up your test data in Loan details data type. For testing purposes, I added two loan numbers.
I will target to update the LoanAmount property value to 999999 in the triggering/invoking activity.
Step 6: Configure the invoking activity.
Add step 1, loop the entire data page results list and update the LoanAmount.
Note: For testing purposes, I am not using any parameter and just updating the same amount in all loan numbers.
Add step 2, Save-DataPage to save the data page with WriteNow parameter checked.
Save the activity.
Step 7: Open the tracer and run the activity.
In the tracer, you find our data save activity is called.
Step 8: Verify if the data instance is updated or not.
No!!!
Why??? – because we just used Write Now = TRUE from the trigger/invoking activity Save-datapage method. But the Write now in Obj-step step of the data save activity is FALSE!
So how to pass the parameter from invoking activity into data save activity??
Don’t worry, Pega takes care of passing the parameter – WriteNow into our database save activity.
In tracer you can find the parameter.
All we need to do is use the parameter.
Step 9: Configure data save activity to use the WriteNow parameter.
Define the Boolean parameter in the data save activity parameters tab.
Add 2 Obj-steps with pre-conditions. If parameter WriteNow is true, then execute the Obj-save with write now step 1.2. If it is false, then execute the Obj-Save without write now step 1.3.
Note: As a best practice, do not use the direct writeNow in obj-save method.
Save the activity.
Step 10: Test the WriteNow parameter
In the invoking activity, make sure to use the WriteNow parameter and run the activity by opening the tracer.
You will the WriteNow parameter is passed to the data save activity and step 1.2 is executed with WriteNow checked while step 1.3 is skipped.
Verify the loan amount in the data type, you should see the value updated.
You don’t want to worry about the WriteNow parameter when the savable data page is invoked from flow or flow action. By default, WriteNow will be false and will always be deferred save.
You can also go through another blog on the same topic – https://onestoppega.com/data-modeling/savable-data-page-in-pega/
There you will find an example of trigger option 2 – using flow action.
As a summary,
– Savable data page can be used in Pega 7.4 and greater versions.
– You can use the database save option to save a single instance and activity to save the list of data instances
– Savable data pages can be explicitly triggered from flow, flow action post-processing and activity method Save-DataPage
– Flow and flow action by default set the WriteNow parameter to false – Deferred save. In athe ctivity method, we need to configure the WriteNow parameter.
– Database save option passes and uses the WriteNow parameter automatically. For activity-based data save, the parameter will be passed by default, but we need to use it to conditionally write or defer the save.
Hope you guys liked this article:) Savable data page concept is a little tricky, but once you understand the entire logic behind it, you will master it.