Announcement

Collapse
No announcement yet.

Not able to Write values into configurationMap

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

  • Not able to Write values into configurationMap

    Hi All,

    Thank you to everyone who is trying to keep this forum alive and active.

    I have an issue while writing values to configuration map from postprocesser. I have script which compares two values and writes value into configuration map but getting the below error

    SOURCE CODE:
    103: if (globalMap.get('Clinician_Length') == parseInt(channelMap.get('Professional District ID'))) {104: var Date = configurationMap.get('Clinician_Date');105: //var Current_Date = new Date(Date);106: var dateString = DateUtil.getDate('yyyy-MM-dd', Date);107: dateString.setDate(dateString.getDate() + 7);108: configurationMap.put('Clinician_Date',dateString); 109: }110: 111: }LINE NUMBER:
    108DETAILS:
    Wrapped java.lang.UnsupportedOperationException
    at 2657ef3f-475a-4798-8598-63bd7a932e50_Postprocessor:108 (doScript)
    at 2657ef3f-475a-4798-8598-63bd7a932e50_Postprocessor:112
    at com.mirth.connect.server.util.javascript.JavaScrip tUtil.executeScript(JavaScriptUtil.java:547)

    Let me know if any one faced similar issue

    Version I am using is 3.11

  • #2
    nextgen-connect-310-user-guide.pdf
    Page 395 first paragraph under Configuration Map.

    Comment


    • #3
      That also seems like very strange data to put at a global level. If you need to persist it across mirth or server restarts you need to write the data to a database. If not you can certainly use other maps for storage. What is your exact use case?
      Diridium Technologies, Inc.
      https://diridium.com

      Comment


      • #4
        Thank you Jkrebs and pacmano. looks like configuration map is read only in channels.

        My exact use case is, I am getting an array of messages and splitting that into different messages and passing as input to another channel. I have configured a date variable in configuration map and upon successful api responses in second channel, I am trying to update the date value through post processer script. I am using a globalmap as I am passing messages through 2 channels and it has a value of array length. I am comparing the array length to a value in last transaction in second channel and based on that I am trying to update the date in configuration map.

        I am sure there will be a better solution to this but let me know if there is anything better that can be done

        Regards,
        Naveen

        Comment


        • #5
          Does that date need to persist if mirth gets restarted?
          Diridium Technologies, Inc.
          https://diridium.com

          Comment


          • #6
            My limited use w/configurationMap has been to centralize and eliminate exposure of DB passwords and connection info from channel transformers and connectors. I'm sure there are far more uses but they're static in my cases.

            For persisting data dynamically across messages and channels, I've used global and global channel maps or simply routing JSON messages. The use of objects helps to minimize the number of java maps. In your use case, I might would consider working w/a global map similar to below:
            Code:
            $g('flag',{length:0,date:DateUtil.getCurrentDate('yyyyMMddHHmmSSss')})
            The object properties can be updated dynamically anywhere in the channels:
            Code:
            $g('flag').date = DateUtil.getCurrentDate('yyyyMMddHHmmSSss')
            Last edited by jkrebs; 07-26-2021, 04:32 AM.

            Comment


            • #7
              pacmano question is most pertinent .

              Comment


              • #8
                I use the configuration map (under Settings... Configuration Map) the same way jkrebs does. In fact in general the only thing in there is a couple of entries for whatever databases mirth will need to interact with. All other configuration data that is not message specific is stored in $g. While I do use $gc at times still, I have found using $g w/JSON objects and array prototype functions a very slick way to handle configuration data that effectively controls message behavior for a multi-tenant or single tenant channel.
                Diridium Technologies, Inc.
                https://diridium.com

                Comment


                • #9
                  Thank you for your time jkrebs and pacmano,
                  Date need not persist but we have changed the solution as we were just thinking of using some reference in order to update the status when all the transactions are completed. I think using global map or global channel map will be an easy method. Will try that and will let you know in case of any issues.

                  once again, ty very much

                  Regards,
                  Naveen

                  Comment

                  Working...
                  X