Announcement

Collapse
No announcement yet.

GlobalMap variable does not work?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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, 04:36 AM.

    Comment


    • #3
      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.

      Comment


      • #4
        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...

        Comment


        • #5
          @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, 06:04 AM.

          Comment

          Working...
          X