web stats
Struggling with deleting some segments - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 08-19-2013, 05:03 AM
mourisj mourisj is offline
Mirth Guru
 
Join Date: Feb 2007
Location: Luxembourg
Posts: 399
mourisj is an unknown quantity at this point
Default Struggling with deleting some segments

I have the following code in my channel:

Code:
for each(ft1 in msg.FT1) {
if (ft1['FT1.7']['FT1.7.1'].toString() == '8V95') {
logger.error("Should be deleted");
	delete ft1;
	}
}
This does only print the error-message, but does not delete the segment !

If I change the code like this:

Code:
for each(ft1 in msg.FT1) {
if (ft1['FT1.7']['FT1.7.1'].toString() == '8V95') {
logger.error("Should be deleted");
	delete ft1['FT1.7']['FT1.7.1'];
	}
}
it will delete the content of FT1-7-1

What am I doing wrong to delete the entire segment ?

TIA fo any help
__________________
JJ Mouris
FFE Luxembourg
IT-Department
Reply With Quote
  #2  
Old 08-19-2013, 06:00 AM
lionelroux lionelroux is offline
OBX.1 Kenobi
 
Join Date: Apr 2013
Posts: 46
lionelroux is on a distinguished road
Default

you can't use ft1 var directly.

here is a code I use in my channel :

for each(node in msg['PID']['PID.21'])
{
if(node != "" && node != undefined){
//logger.debug("Node is "+node);
if(node['PID.21.5'].toString() != 'PI'){
logger.debug("Node "+node+ " is not a PI : deleting !");
//delete node;
delete msg['PID']['PID.21'][0];
}

....


The idea is to delete nodes that are not of type PI.
I needed to have a PI node as the first one.

You can set a count var that you increment each time you delete a node.

Last edited by lionelroux; 08-19-2013 at 06:04 AM.
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 -7. The time now is 12:01 AM.


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