Wednesday, August 13, 2008

Accessing a Message in Different Parts of Mirth

Depending on which part of Mirth you are writing JavaScript code, you need to use different objects to access the same data. It's pretty annoying.

Objects
messageObject.getRawData() - gets raw data - works in transformer, filter, and connector javascript
messageObject.getEncodedData() - works in transformer, filter, and connector javascript
messageObject.getTransformedData() - works in transformer, filter and connector javascript IFF there is a transformer, otherwise returns null
msg - gets array representing XML - works only in transformer and filter, no equivalent in connector

In other scripting situations (like SQL) you can use ${message.rawData} and the like to get rawData, encodedData, and transformedData.

To get a msg object in a connector, check out this posting by ChrisL on the Mirth forum:

If you are using this on the DB Writer Javascript, then the error is occurring because MSG isn't valid there. msg is only available in the transformer and filter.

You can store msg in the transformer with

channelMap.put('msg', msg)

then in your destination DB Writer do:
Code:

var msg = channelMap.get('msg');

2 comments:

Unknown said...

What version of Mirth are u using 1.8 ?

Peter V said...

Maruthi, I am using Mirth 1.7.1.

Labels

Blog Archive

Contributors