No announcement yet.

Accessing Database Reader Settings in Transformers and Filters

  • Filter
  • Time
  • Show
Clear All
new posts

  • Accessing Database Reader Settings in Transformers and Filters

    Using Mirth Connect v3.0.1

    Does anyone know if it is possible to access the "Database Reader Settings" in JavaScript Source Transformer?

    Currently, I am "Using JavaScript" to read from the DB but need to access the DB for other reasons in the Source Transformer and Destination Filters and Transformers. To do this, I need to create GlobalMap variables in the Source JavaScript as follows and use the global variable to open the database in Transformers and Filters.:

    globalMap.put('dbConnectionString', 'jdbc:jtds:sqlserver://localhost:1433/database');
    globalMap.put('dbUsername', 'user');
    globalMap.put('dbPassword', 'password');

    I would like to make use of the "URL:" "Username:" and "Password:" values instead of creating separate globalMap variables in the Source JavaScript.

    Are these values accessible in the Filters and Transformers or is setting globalMap variables the only way.

    I hope this makes sense.


    Last edited by mmaund; 01-29-2014, 08:17 AM. Reason: Add Mirth Version information.

  • #2
    I was poking around a little more and found another thread asking a similar question about a File Reader Channel.

    From there, I was able to get the following to work.

    var dbURL = nelController.getInstance().getDeployedChannelById (channelId).getSourceConnector().getProperties().g etUrl();
    var dbUsername = nelController.getInstance().getDeployedChannelById (channelId).getSourceConnector().getProperties().g etUsername();
    var dbPassword = nelController.getInstance().getDeployedChannelById (channelId).getSourceConnector().getProperties().g etPassword();

    channelMap.put('dbConnectionString', dbURL);
    channelMap.put('dbUsername', dbUsername);
    channelMap.put('dbPassword', dbPassword);

    Would this be considered the correct way to get Source Connector Properties or do I run the risk of this method being deprecated in the future? If so, is there a more direct way?

    Any help would be appreciated.



    • #3
      That certainly does run the risk of being not just deprecated, but removed altogether in a future release. The more "correct" way to go about it is to store those values in the global channel map beforehand using the channel deploy script. Then use those variables both in the source connector settings, and later on in the transformer script.
      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.


      • #4
        I appreciate your quick reply on this.

        That is what I thought. We have been using the globalMap method for quite some time. Although it works well, The way we use this sometimes, setting a channelMap variable for this would work better when we want multiple clones of the same channel working with different sources.

        Short of giving all my reasons, we would like to create one channel, then clone it and minimize the changes we would have to make in the clone. Just changing the source DB would be nice. Using globals, we need to make sure globalMaps in one channel don't stomp on or interfere with globalMaps in another channel running on the same Mirth Instance.

        Any alternative suggestions are welcome but not necessary.