Pega ships a set of standard activities in the Work- class that create work objects, which are the case records in your application. The names look alike, so it helps to know the two choices behind them: commit or not, and covered or not.
The two ideas
- Commit: does the activity save the new record to the database and release its lock straight away, or leave that for later?
- Covered: is the new work object a covered item that belongs to a cover work object (a parent that groups items), or a stand-alone one?
The standard creation activities
| Activity | Creates | Commits? |
|---|---|---|
| Work-.Add | A new stand-alone work object | Yes. It saves the object and releases locks |
| Work-.AddWork | A new stand-alone work object | No. Use this when you want to commit later yourself |
| Work-.AddCovered | A new covered work object | Yes |
| Work-.AddCoveredWork | A new covered work object | No. Current locks are kept |
| Work-.New | A stand-alone work object, called from harness processing, which then displays the entry form | Not in this step |
| Work-.NewCovered | A covered work object, called from harness processing, which then displays the form | Not in this step |
Which one to use
- From a screen where a user clicks Create: the harness uses New or NewCovered for you. You rarely call these yourself.
- From your own activity that creates a case and needs nothing else to happen: Add.
- From your own activity that creates a case and then does more work in the same transaction: AddWork, then a Commit step at the end so everything is saved together.
A worked example
A bank onboarding activity creates a Customer case and, in the same transaction, a Welcome Pack case that must be rolled back if the customer cannot be created.
- Call
Work-.AddWorkfor the Customer case. - Call
Work-.AddWorkfor the Welcome Pack case. - Add one Commit step. Both cases are saved together, or neither is if an error occurs first.
If you had used Work-.Add twice, the first case would already be saved and locked-free before the second one had a chance to fail.
Interview tip
Explain the naming pattern: "Add" saves straight away, "AddWork" does not; "Covered" is for child items under a cover. Then give the two-case commit example. Read on in the Activity label.
No comments:
Post a Comment