Maximo

 View Only
  • 1.  How to modify values in JSON outbound message from Maximo

    IBM Champion
    Posted Tue April 23, 2024 11:41 PM

    Hi All, I'm posting this message for a help on modifying the values in header tag in JSON outbound message from Maximo  as erData.getData or erData.getCurrentData is working only for XML output message. 

    Current set up: 

    1. We have a publish channel with a single object structure (say for example, ASSET) with json mapper processing class.                                       Publish Json ? = False , processing class = com.ibm.tivoli.maximo.fdmbo.JSONMapperExit 
    2. A Json Mapping EXTSYS.PUBLISHCHANNEL.OUT for having a header & assets data to be sent in JSON format. 
    {
    "header": {
          "transactionuniqueid": "1234567321",
          "transactionDateTime": "2024-04-24T00:00:00+00:00"
          "recordCount": "2"
       }, 
       "body": {
          "assets": [
             {
                "Assetnum": "A1001"
             }, {
                "Assetnum": "A1002"
             }
          ]
       }
    }
    3. A User Exit (after processing class) is created for this publish channel   PUBLISH.<PUBLISHCHANNELNAME>.USEREXIT.OUT.AFTER

    This User Exit is used to set values for header attributes to have dynamic values for each message transaction. 

    The problem we are facing is - the erData.getCurrentData("header")  & erData.getChildren("header")- is returning null . I'm able to read the JSON mapped message using erData.getDataAsString() - but not able to modify the values before it is sent to end point. 

    I read from previous posts that we cant modify the string and pass it on to external system. The data in JSON can only be modified using StructureData methods (setCurrentData )

    Please let me know the technical limitation on modifying the tag values in JSON outbound message from Maximo. 

    We are looking to modify the values after parsing it as String, use this payload to call another end point from user exit class & skip transactions in this publish channel for all messages.  resp = JSON.parse(erData.getDataAsString())    resp["header"]["transactionuniqueid"] = "123456789"

    Thanks, 

    Suren



    ------------------------------
    Surendar Balasundaram
    ------------------------------


  • 2.  RE: How to modify values in JSON outbound message from Maximo

    Posted 25 days ago

    Hi Surendar,

    I was wondering if you got this working. I am also looking to change the outgoing JSON in Publish Channel AFTER class and getting the values as null from erData.

    Regards,
    Sarbjeet



    ------------------------------
    Sarbjeet Singh Jassal
    ------------------------------



  • 3.  RE: How to modify values in JSON outbound message from Maximo

    IBM Champion
    Posted 24 days ago

    Hi Sarbjeet, 

    The only method which is working for me on publish channel AFTER after JSON Mapping is erData.getDataAsString() .

    I retrieved the JSON using erData.getDataAsString() and modified the values by String manipulation & JSON set values  [ resp = JSON.parse(erData.getDataAsString()) ].

    The final JSON String is created & using another end point I pushed this desired message to other system.

    response = service.invokeEndpoint("NEWENDPOINT",metaData,jsonNewString )

    Please reply for more information and I'm happy to help.

    Thanks, 

    Suren



    ------------------------------
    Surendar Balasundaram
    ------------------------------



  • 4.  RE: How to modify values in JSON outbound message from Maximo

    Posted 17 days ago

    Hi Surendar,

    Could you please help me on above requirement? I am facing same issue.

    Thanks in advance!



    ------------------------------
    Poorvi Agrawal
    ------------------------------



  • 5.  RE: How to modify values in JSON outbound message from Maximo

    IBM Champion
    Posted 11 days ago

    Hi Poorvi, 

    https://surenmaximoworks.blogspot.com/2023/04/maximo-76x-http-end-point-with-oauth-20.html

    Please let me know the requirement. We can come up with the script that works for it. 

    My case is reading the message from JSON Mapping application in String format, convert it into JSON and update the values. Pass on the JSON as string to another end point using service.invokeEndPoint method

    Thanks,

    Suren



    ------------------------------
    Surendar Balasundaram
    ------------------------------



  • 6.  RE: How to modify values in JSON outbound message from Maximo

    Posted 17 days ago

    If possible, Please share the script sample.



    ------------------------------
    Poorvi Agrawal
    ------------------------------



  • 7.  RE: How to modify values in JSON outbound message from Maximo

    Posted 17 days ago

    Hi Suren,

    Thank you for the response. 

    I ended up writing a processing class on the publish channel and it was easier to modify the outgoing JSON in there.

    I believe it should be same in the Publish Channel external exit automation script as well. I could not write External Exit script as my publish channel had OOB processing class already.

    Thanks,
    Sarbjeet



    ------------------------------
    Sarbjeet Singh Jassal
    ------------------------------



  • 8.  RE: How to modify values in JSON outbound message from Maximo

    IBM Champion
    Posted 11 days ago

    Hi Sarbjeet, 

    In your scenario, is it directly JSON outbound message by selecting Publish JSON ? check box. Can you please let me know on how you read and modified the JSON content. 

    In my case, i need some extra information like total record count, uniqueID for message header. So, I used the JSON Mapping application. by this way, I'm not able to read values from JSON tags in user exit after Automation script.

    Thanks,

    Suren



    ------------------------------
    Surendar Balasundaram
    ------------------------------