No announcement yet.

Mirth Calling VBScript

  • Filter
  • Time
  • Show
Clear All
new posts

  • Mirth Calling VBScript

    Was wondering how i can get Mirth to call a VBScript? There is a similar post from 2006 but i can not figure it our using those instructions.

    I would like to program message changes in VBScript, and Have Mirth call the VBScript to apply the changes to the message.

    I have nothing against Java...I just don't know how to program with it.

    Thanks for any help!

  • #2
    You can do it, but it would be horribly clunky and you'd most likely take a significant performance and functionality hit. It would involve writing the data out to somewhere the vbscript could access it, call the script, then read it back in from wherever the script puts the output. Might even require 2 channels to do it safely as once you've passed it outside Mirth it can no longer track the progress of the transformation; channel A receives data and writes it out to file/database, script processes data and saves it somewhere else, then channel B picks up up and sends it. You start getting to the point where using Mirth becomes largely redundant.

    Don't confuse Java and Javascript; the use of the former is not necessary and is very different to the latter which is fairly trivial to use. There are enough Javascript samples out there that it largely becomes a copy/paste/tweak exercise providing you know some basic fundamentals such as variables, arrays, loops etc...


    • #3
      Thanks for the reply. I was afraid of that.

      2 more questions for you.

      1. Are there any decent tutorials out there that show how to do the "bread and Butter" work that an interface engine does? It seems like every one on the web is dedicated to how to map to a database, or how to create a pdf. ...i'd just like to see how to copy one field to another, or how to concatenate 2 fields together....stuff like that.

      2. If i was going to learn javascript and write scripts in the transformer, would i change the transformer step to "javascript" and put it there?


      • #4
        1. You'll find lots of info on Mirth basics on the wiki. When working with Mirth transformers you can simply paste a message in the template box then drag different elements into the panel. To map the ID in PID2 to PID3 you would use something like this; note you don't have to write any of this whatsoever, you just drag the fields across and it generates the descriptor for you.

        msg['PID']['PID.3']['PID.3.1'] = msg['PID']['PID.2']['PID.2.1'].toString();
        To cat 2 fields together is equally simple:

        var myVar = msg['PID']['PID.2']['PID.2.1'].toString() + msg['PID']['PID.3']['PID.3.1'].toString();
        msg['PID']['PID.2']['PID.2.1'] = myVar;
        2. Just click the transformer type and you get a drop-down list. Select JavaScript.

        Mirth is very friendly, but it doesn't absolve you from needing to know some computing basics such as loops, variables, arrays etc. A lot of common functions can simply be dragged across from the reference pane, then you edit the template to suit your needs.
        Last edited by AlexToft; 04-04-2011, 09:51 AM.