how do I get Mirth connectorMessage.getRawData to return a string?

3.3k views Asked by At

I am trying to get the string representation of the HL7 message input to a channel. Documentation says

var myMessage = connectorMessage.getRawData()

should give me the original unparsed HL7 message. However the type of the data returned is an object and not a string. I tried using .toString() but that doesn't work either. My javascript library code that expects a string and be able to split it fails because what's returned is not a string.

How do I get the original HL7 message string?

2

There are 2 answers

1
Gavin Perkins On BEST ANSWER

On the Summary tab, click on "set data types", and change your inbound connector to "Raw"....after this, connectorMessage.getRawData() should return to you a long string that is the incoming message.

0
agermano On

connectorMessage.getRawData() returns a Java string rather than a javascript string. You can convert to a javascript string by doing.

var myMessage = String(connectorMessage.getRawData())

This is true no matter what you have selected for your data type.