Work with attributes on document instances

As stated in the previous section, attributes are basically attached to activity messages. This means the use of set/get functions read and change the values globally. Such a behavior is enough for simple Mapping Flows.

More complex Mapping Flows might require to read or to change attribute values at the Business Document instance level. A typical situation of this is a Mapping Flow that manages a single message with multiple instances of a Business Document inside.


 Mapping Flow that manages a single message with multiple instances of a Business Document inside


In the diagram above, the identifier of each invoice is computed by the DML Blocks of the Mapping Flow. That id is carried by an attribute named invoiceId which is transferred to individual output messages. To create a Mapping Flow with such a behavior, attributes must be managed at document instance level.

The integration engine offers two built-in functions to set the attributes at document instance level.

These are setDocumentAttribute and setDocumentAttributeToOutput. The former cannot be used outside a Map and addresses the output document of that rule. The later can be used in decision paths only and addresses the document carried by the output whose name is specified as an argument.

The following are examples of the signature of both functions:

setDocumentAttribute(attribute name,
                     attribute field name (optional),

setDocumentAttributeToOutput(output name,
                           attribute name,
                           attribute field name (optional),

All names (attribute, field and output) are expected to be of class S (string) while values can be of any appropriate class except V (raw-data). For structured attributes, the field name is required, but can be omitted for attributes of simple type.

Both functions fail when the class of the value does not match the type of the attribute from its .sh4 file.

Related Links