Designer > Implementing a BPMN Gateway or Control Flow > Scope


BPMN Implementation: Embedded Subprocess
The Scope activity provides a context for a subset of activities. It can contain ault, event, and compensation handling for activities nested within it and can also have a set of defined variables and a correlation set.
A Scope can encompass a logical unit of work, making it manageable to execute, and then, if need be, reverse an activity. For example, if a customer cancels a paid travel reservation, the money must be returned, and the reservation must be canceled without affecting other reservations. By enclosing activities in a Scope, you can create the structure and conditions in which to manage activities as a unit.
Each Scope has a primary activity that can be a complex structured activity.
Required Properties
Optional Properties
Isolated. Refer to Setting Isolated to "Yes" in a Scope
Name. See Selecting Activity Labels
Join Condition. See Creating a Join Condition for an Incoming Link
Suppress Join Failure. See Process Properties
Comment. See Adding Comments to a Process
Documentation. See Adding Documentation to a Process
See Setting Visual Properties and Using Your Own Library of Images
Execution State. See Viewing the Execution State of an Activity or Link
Extension Attributes and Extension Elements. See Declaring Extension Elements and Attributes.
To build a Scope:
  1. 1. From the Control Flow palette, drag an Embedded Subprocess activity to the Process Editor canvas.
  2. You can add a background color to the embedded subprocess if it is collapsed. Right-mouse click on the embedded subprocess and select Collapse Container. The color property will appear in the Properties view.
  3. 2. In the Properties view, set Isolated to Yes or No.
  4. 3. On the Process Editor canvas, right-mouse click the Scope activity to add declarations, including:
  5. 4. From the Handlers palette, add event fault and compensation handlers:
  6. 5. From the Task palette, drag activities to the Scope container, and select activity properties.
The following illustration shows a sample scope activity with all handlers displayed.
You can save an activity, or group of activities to the Custom palette for reuse. Because a Scope can be complex, it is a good candidate for reuse. For more information, see Creating a Custom Activity.
XML Syntax
<scope isolated="yes|no"? exitOnStandardFault="yes|no"?
<scope isolated="no">
<invoke partnerLink="Seller" portType="Sell:Purchasing"
<invoke partnerLink="Shipper" portType="Ship:Orders"
See also:

Setting Isolated to Yes in a Scope

Two scopes can run at the same time. For example, at the end of the year, a bank executes two activities for each account: add interest and charge credit card costs. These activities can be executed in any order. However, since they both update the account, they cannot execute at the same time.
To ensure that variables referred to within each scope do not conflict, you can enable the isolated property. This property enables serialized access to variables, so that one scope has access to the shared variables and must finish using them before the concurrently running scope can use them.
Isolation is not enabled during compensation. For more information, see Compensation.

Using a Termination Handler for a Scope

BPMN Implementation: Cancel catch event
Activities can be terminated in a process through fault handling, early termination via a completion condition on a parallel forEach or through the execution of a Process Developer extension break activity. The Scope is the only activity that provides a means to control what happens when an activity is terminated. The termination handler for a scope is enabled while the scope is executing its main activity or its event handlers. The termination handler is disabled as soon as the scope completes its execution or if the scope's fault handlers execute. If a scope is eligible for termination, the termination of a scope begins by terminating its primary activity and all running event handler instances. Following this, the custom <terminationHandler> for the scope runs. If there is no termination handler for the scope, the default termination handler executes.
The default termination handler is:
For the main discussion of a scope's properties, see Scope.

Lifecycle of a Scope

When a Scope activity executes, it immediately registers any event messages or alarms with the engine prior to the execution of its child activity. Once registered, these messages and alarms are eligible to execute until the scope's child activity completes.
A Scope is said to complete normally when it completes without a fault having been caught or rethrown. If a Scope completes normally, it is eligible for compensation.