web stats
Using variable in delete msg funtion? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 02-23-2011, 06:48 AM
daveylin daveylin is offline
Mirth Newb
 
Join Date: Jun 2008
Posts: 17
daveylin
Default Using variable in delete msg funtion?

I am trying to delete all segments except the MSH and PID in a message and trying to pass a variable to the delete msg function but it always errors out. If I explicitly put the segment name though, it works...

Am I doing something wrong?

Thanks,

David

for each (seg in msg.children()) {
var segname = seg.name().toString();
if (seg.name().toString() != "MSH" || seg.name().toString() != "PID" || seg.name().toString() != "EVN") {
delete msg['PV1']; works
delete msg[seg.name().toString()]; doesnt work
delete msg[segname]; doesnt work
}
}
Reply With Quote
  #2  
Old 02-23-2011, 08:30 AM
cward cward is offline
 
Join Date: Feb 2008
Posts: 84
cward is an unknown quantity at this point
Default

Try this think you need to replace the || with && when using the Not equal. The following code worked for me:

for each (seg in msg.children()) {
if (seg.name().toString() != "MSH" && seg.name().toString() != "EVN" && seg.name().toString() != "PID") {
delete msg[seg.name()];
}
}
Reply With Quote
  #3  
Old 03-03-2011, 04:19 PM
daveylin daveylin is offline
Mirth Newb
 
Join Date: Jun 2008
Posts: 17
daveylin
Default

Thanks! That was it.

Also I didnt need the toString in the seg.name.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 07:31 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation