Sometimes you need to modify a value inside a received message. This can be done using a JavaScript filter and specifying the field value that will be changed.
- Add a Javascript filter to your route.
- Add the Definition file to the route. This is required to specify the field whose value is going to be modified. For example, if the field we wish to edit is called
Field
in a Segment calledSegment
, the definition must specify these message elements. - Configure the filter, as shown in the following diagram.
The only configurable element of the JavaScript filter is the code that is executed for each collection of messages that passes through the filter. An outline is already provided, with examples of how the message body can be edited, or a property set on the message.
The first argument to setField()
specifies the field on the message that we wish to set. All elements leading to the field must be specified, separated by a '/' or a '.' character for an EDI message definition, or using XPath notation for an XML message. The second argument specifies the value we wish to set the field to.