Pega standard Work object creation activities

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

ActivityCreatesCommits?
Work-.AddA new stand-alone work objectYes. It saves the object and releases locks
Work-.AddWorkA new stand-alone work objectNo. Use this when you want to commit later yourself
Work-.AddCoveredA new covered work objectYes
Work-.AddCoveredWorkA new covered work objectNo. Current locks are kept
Work-.NewA stand-alone work object, called from harness processing, which then displays the entry formNot in this step
Work-.NewCoveredA covered work object, called from harness processing, which then displays the formNot 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.

  1. Call Work-.AddWork for the Customer case.
  2. Call Work-.AddWork for the Welcome Pack case.
  3. 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