An activity often needs to run another activity. Pega gives you two ways to do it, and the difference is simple but easy to forget under interview pressure: Call comes back, Branch does not.
Call
The Call method runs another activity and then returns control to the step after the call. It works like calling a function. Any steps that follow the Call step still run.
Branch
The Branch method hands over to another activity found through rule resolution and never returns. The original activity pauses, the branched activity runs, and when it finishes, the original one ends too. Any steps after the Branch step are skipped.
Comparison
| Call | Branch | |
|---|---|---|
| Control after the target activity finishes | Returns to the next step | Does not return; the calling activity ends |
| Steps after it | Run normally | Never run |
| Feels like | A function call | A one-way jump to another activity |
| Typical use | Reuse logic, then carry on | Last step, hand the rest of the work to another activity |
A worked example
Suppose a bank activity ProcessTransfer has these steps:
- Call
ValidateAccounts - Call
PostToLedger - Branch to
SendConfirmation - Property-Set
.Status= Done
Steps 1 and 2 return, so step 3 runs. Step 3 branches to SendConfirmation. When that activity ends, ProcessTransfer also ends, so step 4 never runs and the status stays unchanged. That is why a Branch is usually the last step of an activity.
Related ways to stop an activity
- Exit-Activity ends the current activity and returns to the caller.
- Activity-End ends the current activity and every activity that called it.
See our post on Activity-End and Exit-Activity for the difference.
Interview tip
Answer with one contrast: "Call returns to the caller, Branch does not." Then say Branch is used as a final hand-off and that steps after it are skipped. Browse the Activity label for more.
No comments:
Post a Comment