web stats
Looping through a repeating segment using a $gc variable - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 07-12-2018, 05:21 AM
J R J R is offline
Mirth Newb
 
Join Date: Nov 2017
Posts: 24
J R is on a distinguished road
Default Looping through a repeating segment using a $gc variable

I am setting a global channel variable in a startup script to read from a CSV file. I reference it once in the PV1 segment and it works great, but I also need to lop through the FT1 segments and use it there. I do not get any result when I try (it leaves the original value) so I wonder if I am looping incorrectly:

Code:
var ft1201 = '';

for each(ft1 in msg.FT1)
	{
		var ft1201 = ft1['FT1']['FT1.20']['FT1.20.1'].toString().toUpperCase();

		if ($gc('PhysICGuidtoTUGID')[ft1['FT1']['FT1.20']['FT1.20.1'].toString().toUpperCase()])
			{
				ft1201 = $gc('PhysICGuidtoTUGID')[ft1['FT1']['FT1.20']['FT1.20.1'].toString().toUpperCase()];
				ft1['FT1']['FT1.20']['FT1.20.1']=ft1201;
			}
	}
Reply With Quote
  #2  
Old 07-12-2018, 05:49 AM
J R J R is offline
Mirth Newb
 
Join Date: Nov 2017
Posts: 24
J R is on a distinguished road
Default

Never mind, I remembered that when you create a loop, you have to omit the parent segment of the message tree when you refer to it within the loop.

Removing the below fixed it and it works great now:
['FT1']
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 02:35 PM.


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