web stats
GlobalMap variable does not work? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 11-04-2014, 04:35 AM
ferdinand ferdinand is offline
OBX.1 Kenobi
 
Join Date: Sep 2014
Posts: 34
ferdinand is on a distinguished road
Default GlobalMap variable does not work?

Hi guys,I have a system with two channels

I want to use a variable from channel A on channel B

in channel A I have used in source transformer
Mapper
Variable njusa
mapping msg['PID']['PID.2']['PID.2.1'].toString()
add to : Global Map


And in channel B I want to retrieve this variable with the following in destination transformer:
$('njusa').toString()==tmp['PID']['PID.2']['PID.2.1'];

But no way, I cant achieve this to work.

¿What am I doing wrong? I have searched dozens of posts...

BTW I'm using mirth 3.1.0

thanks in advance
Reply With Quote
  #2  
Old 11-04-2014, 05:31 AM
bobekos bobekos is offline
OBX.1 Kenobi
 
Join Date: Oct 2014
Posts: 26
bobekos is on a distinguished road
Default

I'm only using JavaScript Transfomer...so here is my solution:

Source Transfomer:
PHP Code:
var sData msg['PID']['PID.2']['PID.2.1'].toString();
if (
sData.length == 0){
     
sData 'you default value';
}
globalMap.put('njusa',sData); 
Dest.Transfomer
PHP Code:
var sData globalMap.get('njusa'); 
btw. what is this???
PHP Code:
$('njusa').toString()==tmp['PID']['PID.2']['PID.2.1']; 
If you want to assign the value of 'njusa' to the tmp msg please use:
PHP Code:
tmp['PID']['PID.2']['PID.2.1'] = sData

Last edited by bobekos; 11-04-2014 at 05:36 AM.
Reply With Quote
  #3  
Old 11-04-2014, 06:46 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

A better solution would be to add the variable to the channel map (not the global map). Then, use the Message Metadata table on the Channel Writer to forward that channel map variable to the downstream channel.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #4  
Old 11-04-2014, 06:51 AM
ferdinand ferdinand is offline
OBX.1 Kenobi
 
Join Date: Sep 2014
Posts: 34
ferdinand is on a distinguished road
Default

Quote:
Originally Posted by bobekos View Post

btw. what is this???
PHP Code:
$('njusa').toString()==tmp['PID']['PID.2']['PID.2.1']; 
[/PHP]
My stupid approach to try it to work.
I have read somewhere that if you would like to access a variable then you have to write $('variable') no matter if it is global, channel or whatever.

So, do I have to use a temporary variable each time I have to access to this (sData) ?

Thanks Bobekos, your javascript works...
Reply With Quote
  #5  
Old 11-04-2014, 06:58 AM
bobekos bobekos is offline
OBX.1 Kenobi
 
Join Date: Oct 2014
Posts: 26
bobekos is on a distinguished road
Default

@ferdinand
no problem!
So, do I have to use a temporary variable each time I have to access to this (sData) ?
PHP Code:
tmp['PID']['PID.2']['PID.2.1'] = globalMap.get('njusa'); 
It is the same thing.
@narupley
Yeah your right! But this function is new or i am blind. How can i access to the variable on another channel? For example in javascript?

Edit:
My mistake. I don't read the Metadata information. The variable is in the source map of the channel. Again learned something new.

Last edited by bobekos; 11-04-2014 at 07: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 -8. The time now is 02:38 AM.


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