Announcement

Collapse

Mirth Connect 4.1.0 Released!

Mirth Connect 4.1.0 is now available as an appliance update and on our GitHub page. Mirth Connect 4.1.0 includes new features such as new event log messages, additional fields to the Welcome to Mirth Connect screen, new information included in alerts as well as many smaller changes, updates, and improvements. This release also contains several 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

How to reference a field in a responseMap object

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

  • How to reference a field in a responseMap object

    Hi everyone,

    This is probably baby knowledge, but I can't find any examples and I've tried 40 different variations without a win:

    I've got destinations that return JSON objects which I store in the responseMap like this:

    responseMap.put('someMessage', response.getMessage())

    The object is like this (more or less)

    HTML Code:
    {
        "id": 12345,
        "success": true
    }
    I need to be able to check the success status in a subsequent destination to determine whether to continue processing

    How do I check the "success" field value?

    Thanks!
    Last edited by panicdrone; 07-29-2022, 10:57 AM.

  • #2
    You do not need to put stuff in the response map, it is already there.

    For example assuming your first destination number 1, the value of the succes field name in the JSON can be retrevied downstream like:

    JSON.parse($('d1').getMessage()).success
    Diridium Technologies, Inc.
    https://diridium.com

    Comment


    • #3
      Excellent, thank you! This is a simplified version of what I did: var pfResp = JSON.parse(responseMap.get('someMapObjectName')).s uccess

      The source for my channel can receive multiple message types and based on that one of several different destinations hits an API with that message. The responses are identical so that's why I put the response into the responseMap. I never know which destination is going to be hit, but I know one will be. Thanks again

      Comment


      • #4
        Not sure I undestand that. You are duplicating when you don't need to. You know what destination it hit because you can check that at any time.
        Diridium Technologies, Inc.
        https://diridium.com

        Comment


        • #5
          That's why it says "Mirth Newb" next to my name. Still stuff I'm learning. How do I check all possible responses and find out which one was "SENT" ?
          Last edited by panicdrone; 08-01-2022, 05:31 PM.

          Comment


          • #6
            Just iterate through the destinations and check which one(s) were SENT.

            Also, if you know the logic for when a destination should run or not when you receive the message, you should be using destination set filtering anyway.
            Diridium Technologies, Inc.
            https://diridium.com

            Comment


            • #7
              see https://forums.mirthproject.io/forum...ch-destination
              Diridium Technologies, Inc.
              https://diridium.com

              Comment


              • #8
                This was very useful. Thanks!!

                Comment

                Working...
                X