Skip to main content

Defining the context Object

Defining the context Object

Each BPL business process has a context object that provides information available for use in the BPL logic. To define this object, do the following in the BPL Editor:

  1. Click the Context tab.

  2. Modify the following settings:

    • Request Class—Choose the class of the incoming request for this process.

    • Response Class—Choose the class of the response returned by this process.

    • Context Superclass—Use this option to provide custom context properties, in a different way than adding to the Context properties list, described next. To use Context Superclass, create a custom subclass of Ens.BP.ContextOpens in a new tab. In this subclass, define class properties to use as context properties. Use the name of this class as the value of Context Superclass in the business process. Then when you create <assign> actions, for example, you can choose these custom properties in addition to the standard properties of the context object.

  3. To add a property, click the plus sign next to Context properties.

    Then enter values in the following fields:

    • Property Name—Must be a valid identifier.

    • Choose if the property data is one of the following: Single Value, List Collection, or Array Collection

    • Property Type—Type of this property including parameters.

      Enter a data type class name in the Type field or click the magnifying glass to browse for a class you want to use as a data type.

    • Default Value (ignored for collections)—Enter an initial expression for a single value data type.

    • Instantiate—Select this check box for object-valued properties if you want the object to be instantiated when it is created.

    • Description—Enter an optional description of the context property.

  4. Click OK to save your changes or click Cancel to discard them.

To set property parameters such as MINVAL, MAXVAL, MINLEN, MAXLEN, or others, add data type parameters to a context property when you first add the property, or at any subsequent time, by inserting a comma-separated list of parameters enclosed in parentheses after the data type class name. That is, rather than simply entering %StringOpens in a new tab or %IntegerOpens in a new tab, you can enter data types such as:

%String(MAXLEN=256)
%Integer(MINVAL=0,MAXVAL=100)
%String(VALUELIST=",Buy,Sell,Hold")

Once you have defined properties of the context object, you can refer to them anywhere in BPL using ordinary dot syntax and the property name, as in: context.MyData

For reference details, see the following resources:

By default, the ruleContext passed to the rule is the business process execution context. If you specify a different object as a context, there are some restrictions on this object: It must have a property called %Process of type Ens.BusinessProcessOpens in a new tab; this is used to pass the business process calling context to the rules engine. You do not need to set the value of this property, but it must be present. Also, the object must match what is expected by the rule itself. No checking is done to ensure this; it is up to the developer to set this up correctly.

FeedbackOpens in a new tab