Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working with the msg object in external library #19

Open
redeemefy opened this issue Mar 6, 2020 · 2 comments
Open

Working with the msg object in external library #19

redeemefy opened this issue Mar 6, 2020 · 2 comments

Comments

@redeemefy
Copy link

redeemefy commented Mar 6, 2020

Our team wrote/writing a java library to be used within connect. We are running into an issue where I need to pass msg["some..."] as a parameter without the .toString(). Inside the function I want to determine if the msg["some..."] is an xml or json.

From the library I logger.warn(":::: JAVA TYPE :::: " + value.javaClass) // org.mozilla.javascript.xmlimpl.XMLList. Happened that this class comes from a private package.

Screen Shot 2020-03-06 at 8 38 59 AM

Is there a work around or a way to work with the msg object in the external library?
In other words, I want to stringify the XML that I'm passing.

@redeemefy
Copy link
Author

UPDATE:
I'm trying to move this very functionality inside Mirth and still have issues with this. I don't know if this is a bug or not. I'm trying to reach a field within a segment logger.debug(msg['PID']['PID.4']['PID.4.1'].name()); and I get back TypeError: name is not a function, it is xml.. In the Message Trees I see that the node is there with an [empty] value. I tried to do the same thing with a different field and I do get the node name, for instance logger.debug(msg['PID']['PID.5']['PID.5.3'].name()); which its value also [empty] but I get back PID.5.3.

Why the inconsistency?

@tonygermano
Copy link
Collaborator

Your actual inbound message probably does not have a PID.4.1 node.

The outbound template in your transformer, if present, gets serialized to the tmp variable.

The inbound template is only there for drag-and-drop purposes. msg will be the contents of your message, which doesn't necessarily look anything like your inbound template that you view in the Message Trees tab.

To your original question, if you are trying to stringify the XML for a node, use msg['PID']['PID.4']['PID.4.1'].toXMLString(). That will return an empty string if the node doesn't exist instead of throwing an exception and include the element name even if the node only contains text children.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants