Announcement

Collapse

Mirth Connect 3.12.0 Released!

Mirth Connect 3.12.0 is now available as an appliance update and on our GitHub page. This release includes database performance improvements, improves visual HL7 representation, message pruning, keystore handling, PDF generation, community contributions, and fixes several security vulnerabilities. This release also contains many improvements to commercial extensions. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

Problem with variable

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

  • Problem with variable

    Hallo,

    the following settings are use:
    i add a global function to code template name :isEmpty type: global
    here the source :

    function isEmpty(val)
    {
    if( val.length == 0 || val == """")return fals;

    for(var i=0;i<val.length;i++) {
    if ( (val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&& (val.charAt(i)!="\r")){return false;}
    }return true;


    }

    i add step in the source transformer :
    variable type channel name : MsgType

    Mapping :msg['MSH']['MSH.9']['MSH.9.1'].toString()

    then some variables in steps following.

    last step is type javascript with name validate
    .....

    if(isEmpty($('MsgType')))
    errormessage = errormessage +"# MESSAGE TYPE is empty";

    ....

    the result is anytime false!?

    i try also the following :
    if(isEmpty(channelMap.get('MsgType')))
    or
    if(isEmpty(channelMap.get("MsgType")))
    or
    var temp = channelMap.get("MsgType")
    if(isEmpty(temp))

    all this get result false.

    if i try this:
    if(isEmpty(msg['MSH']['MSH.9']['MSH.9.1'].toString()))

    this work

    my variable is not empty i see that in the dashbord -> mychannel-> source->mapping the value are always "ADT"

    i dont know what are wrong!?

    regards

  • #2
    Re:Problem with variable

    Maybe you should get the value into a JS variable before calling the global function, not in a velocity one, like this:

    -- in the JS step
    var msg_9_1 = msg['MSH']['MSH.9']['MSH.9.1'].toString();
    if(isEmpty(msg_9_1)) {
    .....
    }

    Are you controlling in the IsEmpty function if the value is null ? try to put there some logger.error() statements to check the value that IsEmpty is getting

    Hope that helps

    Comment


    • #3
      Re:Problem with variable

      thanks, bat see my post bevor. that works , i know. but not from a channelvariable.

      regards

      Comment

      Working...
      X