Instance Prefixes

Normally rules do not distinguish between instances of the same business object. Instances are resolved from the Context and if there is more than one instance of the object in the Context the action is applied to all such instances.

However, in certain relatively rare circumstances it may be necessary to distinguish between instances of the same business object stored in the Context. In these cases special instance prefixes added to the attribute path just before the name of the business object can be used.

Consider, for example, the following rule attached to a business object SystemUser, which checks that there is only one instance of the SystemUser with the specified login name in the system:

IF EXISTS SystemUser WHERE (SystemUser.LoginName = ThisSystemUser.LoginName) THEN 
 REPORT ERROR 'User with this name already exists'. 

Here the This prefix added to the name of the business object (ThisSystemUser.LoginName) indicates the SystemUser instance located in the Context as opposed to the SystemUser instances in the rest of the system, which are searched by the aggregate operation.

There are several special prefixes that are used in the Rule Language to distinguish between instances of business objects in the Context:

  • This
  • That
  • Other
  • LoggedIn
  • Added
  • Removed
  • Changed
  • Failed

This prefix indicates the first instance of an object that has been added to the Context by any of the scenarios described in the How Context is Formed section.

That prefix indicates the second instance of an object added to the Context. Usually it is the instance found by the FIND or PICK FROM action or created by the CREATE or ENTER NEW actions. For example, consider the process that has the following rules defined:

  • FIND Policy WHERE Policy.MyDriver.Name='John Smith' 
  • IF ThisPolicy.Excess > ThatPolicy.Excess THEN...  

Let us assume that the above process has the Policy object as its input. When this process is executed the instance of the Policy object being the input of the process is put in the Context first. This instance may be referred to by the This prefix. The first rule of the process finds another instance of the Policy object (the one belonging to John Smith). The result is put into the Context as well. As John Smith’s policy is the second instance of the Policy object in the Context it will have the That prefix, so the second rule will compare the excess of the process input instance with the excess of John Smith’s policy.

If the FIND rule found more than one instance of the Policy object, then these instances could be referred to with the Other prefix – so we could refer to the initial policy as ThisPolicy and to all other policies as OtherPolicy.

The LoggedIn prefix can be used in conjunction with the name of the business object that is using the system (member of the SystemUser group) to refer to the instance of the currently logged in user. For example,

IF LoggedInAssociate.LoginName='john' THEN DoSomething 

Added, Removed and Changed prefixes are used in conjunction with WAS CHANGED expression, which tracks changes in the list – see Evaluation of Rules Containing WAS CHANGED Expressions.

The Failed prefix is used to indicate the object that caused a failure in process failure rules – see Process Failure Rules.

  • Last modified: 2023/07/16 02:25