Data field assignment

Data field assignment is a way to apply default values to data fields at specific points in a workflow. The assignments are done, either unconditionally or limited by certain conditions, on every decision. The workflow, node, and task XML descriptors support the assignment operation.

In addition to the default values, one data field can be assigned to another. A data field can also be identified as not current, or selected to be returned to the client application that is connected to Business Rules.

Assignments are done at entry to the component or exit from the component. The following XML is an example of assignment statements.
<assignments>
  <assignment field="ibmValProductId"  type="string"  value="FMX" 
              executionPoint="onEntry"/>
  <assignment field="ibmNprBdCategory" type="decimal" value="0" 
              executionPoint="onEntry"/>
  <assignment field="ibmNprEndpoint"   type="field"   value="ibmIntSubEndpoint" 
              executionPoint="onExit" conditions="notCurrent,sourceCurrent" 
              results="SUCCESS"/>
</assignments>
In this example, ibmValProductId is set to FMX and ibmNprBdCategory is set to zero on entry into the node. This assignment happens each time that the node is run. ibmNprEndpoint is set to the value in ibmIntSubEndpoint on exit from the node, but only if all of the following conditions are true.
  • The result from processing the node is success.
  • The ibmNprEndpoint field is notCurrent.
  • The source field ibmIntSubEndpoint is current.
The following table shows which assignment XML attributes are required and which are not.
Table 1. Assignment XML required attributes
Attribute name Required
field Yes
value No
type No
notCurrent No
executionPoint No
conditions No
results No

The following sections provide more information about the assignment XML element.

field attribute

The field attribute specifies the data field that a value is being assigned to. The following table shows the values that are available for the field attribute.
Table 2. Assignment XML field attribute
Attribute value Description
Data field name Specify the name of the data field to be modified by the assignment.

type attribute

The type attribute specifies the type of data to assign to the data field in the field attribute.
Note: This attribute is ignored when the notCurrent attribute is set to true.
The following table shows the values that are available for the type attribute.
Table 3. Assignment XML type attribute
Attribute value Description
string The type of the value that is being assigned to the data field is a hardcoded string. This attribute value is the default.
decimal The type of the value that is being assigned to the data field is a hardcoded number.
hex The type of the value that is being assigned to the data field is a hardcoded hexadecimal number.
pack The type of the value that is being assigned to the data field is a hardcoded packed number.
field The value that is being assigned to the data field is the value from another data field.
functionName The value that is being assigned to the data field is the value that is returned by the function. The function names are case-sensitive. For more information about using functions in the assignment statement, see Using functions for data field assignment.

value attribute

The value attribute provides the value that is copied or assigned to the data field in the field attribute.
Note: This attribute is ignored when the notCurrent attribute is set to true.
The following table shows the values that are available for the value attribute.
Table 4. Assignment XML value attribute
Attribute value Description
xxxx The hardcoded value that is assigned to the data field in the field attribute.
Data field name The name of the data field whose value is copied to the data field in the field attribute. The value is copied when the type attribute is set to field.

notCurrent attribute

A client application interfaces with the Business Rules Server by beginning with a single initialize (Init) message followed by at least one decision message. Both messages transmit data fields to the server.

When a data field is established for a client session, it is maintained in a list that is separate from all of the other current client sessions. When the field is set with a value, it is considered current for the current message. Anytime that the data field is set, the field is marked current. It remains current until the next message is received from the client application.

Fields are marked not current when the decision message arrives and just before the incoming fields are ingested. The previous values of the fields are not discarded.

For example, assume that the ibmSortType field is sent on the initialize message and ibmNprAmount is sent on the decision message. ibmSortType is current only during the processing of the initialize message and not current on the subsequent decision messages. Workflows can be designed to read the value at any time and know whether the value is good, even if it is not current. For ibmNprAmount, it is a problem to use the value of a previous transaction if the client did not send it on the decision message. A node or user exit needs to test for this condition.
Note: This example is a hypothetical condition as clients usually send the amount field.
When a field is assigned from another field, the current state of the source field is assigned, too. For example, if ibmNprEndpoint is current and has the value A, and ibmIntSubEndpoint is not current with the value B, ibmNprEndpoint is changed to not current with value B.
<assignment field="ibmNprEndpoint" type"field" value="ibmIntSubEndpoint"/>
The following table shows the values that are available for the notCurrent attribute.
Table 5. Assignment XML notCurrent attribute
Attribute value Description
false Attribute is ignored. This attribute value is the default.
true Indicates that the field is not current. The type and value attributes are ignored.

executionPoint attribute

The executionPoint attribute indicates when the value is copied or assigned to the data field in the field attribute. The following table shows the values that are available for the executionPoint attribute.
Table 6. Assignment XML executionPoint attribute
Attribute value Description
onEntry Does the assignment when the workflow, node, or task is entered and before any user exits are called. This attribute value is the default.
onExit Does the assignment after any user exits are called and before the workflow, node, or task exits.

conditions attribute

You can specify multiple condition settings for the conditions attribute. Separate each of the condition settings with a comma. For example, zero,notCurrent applies the assignment to the data field if the data field has a value of zero and is not current.

The following table shows the values that are available for the conditions attribute.
Table 7. Assignment XML conditions attribute
Attribute value Description
{blank} Set this attribute to blank if no conditions are needed for the data field assignment.
empty Does the assignment if the field has a zero length. The assignment is also done if the data field is marked not current.
zero Does the assignment only if the field has a zero value.
notCurrent Does the assignment only if the field was not set on the current transaction.
sourceCurrent Does the assignment only if the source field was set on the current transaction. The assignment is done only when the type attribute is set to field.
DF1 operator DF2 Does the assignment only if the specified comparison of two string data fields, DF1 and DF2, is true. The comparison is case-sensitive. The values available for the operator are:
  • EQ - the data fields are equal.
  • NE - the data fields are not equal.
  • LT - field DF1 is less than field DF2.
  • LE - field DF1 is less than or equal to field DF2.
  • GT - field DF1 is greater than field DF2.
  • GE - field DF1 is greater than or equal to field DF2.
DF operator 'Constant' Does the assignment only if the specified comparison of a data field, DF, and a hardcoded value, Constant, is true. The values available for the operator are:
  • EQ - the data field equals the constant value.
  • NE - the data field does not equal the constant value.
  • LT - the data field is less than the constant value.
  • LE - the data field is less than or equal to the constant value.
  • GT - the data field is greater than the constant value.
  • GE - the data field is greater than or equal to the constant value.
DF MATCHES 'Constant' Does the assignment only if the data field, DF, matches the regular expression that is specified as the Constant value.
DF CONTAINS 'Constant' Does the assignment only if the data field, DF, contains the regular expression that is specified as the Constant value.
DF IS notCurrent Does the assignment only if the data field, DF, was not set by the current transaction.
DF IS current Does the assignment only if the data field, DF, was set by the current transaction.
DF IS currentAndNotEmpty Does the assignment only if the data field, DF, was set by the current transaction and has a length that is greater than zero.

results attribute

The results attribute controls whether the value is copied or assigned to the data field in the field attribute based on the results of running the workflow, node, or task. The following table shows the values that are available for the results attribute.
Table 8. Assignment XML results attribute
Attribute value Description
{blank} Set this attribute to blank to always do the assignment. The result of processing the workflow, node, or task is ignored. This attribute value is the default.
SUCCESS Does the assignment only when the processing of the workflow, node, or task was successful.
FAILURE Does the assignment only when the processing of the workflow, node, or task was not successful.