Use a savable data page to save data to a system of record without using an activity.
By keeping the persistence logic with the data page, the logic is reusable and consistent.
You can create a save plan for a savable data pages in the following ways:
- Save data directly to the database by selecting Database save in the Data save options section of the Definition tab of your data page.
- Process the data before saving it into the database by selecting
Activity in the Data save
options section of the Definition tab of
your data page. You would then use, for example, an
Connect-REST/SOAP, step, or other code to save the data page.
- Save data to external systems of record by using Robotic automation or Robotic desktop automation.
- Save and persist data by selecting a REST Connector. You can make a REST call by selecting a POST, PUT, or PATCH method.
You can trigger the saving of a data page in the following ways:
- In a Flow Action, you can list the data pages to save as part of postprocessing. You can optionally list a When rule for each data page to control which data pages are saved after the Flow Action, based on conditional logic.
- In a Flow, use the Save Data Page smart shape after an assignment.
- Instead of using a Flow Action or Flow, you can use the
Save-DataPage method to save the data page to a
database or call a connector if you are saving to an external database.
Note: If you use the data page with a save option to save work items, this option unlocks the current work item as well as its parent work items. Unlocking parent items degrades performance, and other users cannot access the parent items while they are unlocked. To save work items, use the Obj-Save activity method or the RecalculateAndSave API with clipboard pages.
When you save a savable data page, there is an option for WriteNow. When true, the save occurs immediately as an independent transaction. When false, the save is deferred and is included in a larger transaction that they will eventually commit.
Flow Actions and the flow Flow smart shape always set WriteNow to false when they save a savable data page. The activity method exposes WriteNow as a parameter and you set its value.
When you use the Database save save plan option, you do not have to set WriteNow; the Pega Platform sets it.
When you use the Activity save plan option, include the WriteNow parameter. Its value is based on what the caller specified when it saved the data page. If your activity persists the data using one or more Obj-Save steps, set the WriteNow value on the Obj-Save steps based on the value of this parameter. If your activity persists the data using other methods, such as a connection, ignore the value of this parameter and include rollback and compensating actions in your process to handle failures when some persistence already occurred.
WriteNow is not available for robotic automation saves. Robotic automation saves are done as independent transactions. If you need rollback or compensating actions in the case of an error, include that logic later in your process.
If you add a save option, you must specify a When rule.
If you have multiple save plans, the system evaluates the When rule for each save plan, which means that every save plan whose When rule evaluates to true is executed. The Otherwise save option is executed if the When rule for every save plan evaluates to false.
- Creating a data page save plan
Use a save plan to create a data page that you can then use to save data to a system of record.
- Adding a Save data page step
You can save data that is in a data page to a system of record by adding a Save data page step to a process in the case life cycle. This can improve performance and reduce memory requirements when multiple requestors in an application need to access the same information.
- Saving data in a data page when running an activity
You can save data that is in a data page to a system of record by including the data page in an activity. By using an activity, you can choose whether to save the data in conjunction with the rest of the transaction, or independently as a separate transaction.