Maximo Open Forum

 View Only
  • 1.  Maximo Automation Script for Integration - JSON

    Posted 06-30-2020 08:38
    I'm writing a script for integration to modify JSON input and save to maximo. First I converted the StructureData erData input to JSON object like this;

    var resp = JSON.parse(erData.getDataAsString());


    Then I modified the JSON object to add additional properties. How can I convert back my modified JSON object to StructureData erData so that I can save it to Maximo.

    Thank you. Regards


    #Integrations

    ------------------------------
    Selvam Manohar
    Comm-IT Consultancy Services
    ------------------------------


  • 2.  RE: Maximo Automation Script for Integration - JSON

    Posted 07-01-2020 09:27
    I don't think it's possible to replace the message like that. We've always directly manipulated erData (such as using erData.setCurrentData("ATTRIBUTENAME","Value")) or utilized object structure processing scripts where we adjust the values as it's being set to the MBO records. 

    If you could walk through the scenario a bit further as to why you're manipulating in JSON I can probably help explain how to do it with the StructureData object itself.

    ------------------------------
    Steven Shull
    Projetech
    ------------------------------



  • 3.  RE: Maximo Automation Script for Integration - JSON

    Posted 07-01-2020 23:22
    I tried to manipulate erData directly like erData.setCurrentData("ATTRIBUTENAME","Value")). However, I couldn't use getChildrenData and createChildrenData method as the input is in JSON format.

    Our scenario as follow;

    1. Maximo received JSON request data. The data contains a parent and nested child arrays.
    2. Automation script to manipulate json data. We need to add another level of child into existing data before saving to maximo.
    3. Data will be saved to PO with POLINE and POCOST.

    Thank you

    ------------------------------
    Selvam Manohar
    Comm-IT Consultancy Services
    ------------------------------



  • 4.  RE: Maximo Automation Script for Integration - JSON

    Posted 07-02-2020 02:38
    Hi Selvam,

    I have recently faced this issue and if not for json data then Structure data has methods to add child objects into the xml.
    I resolved the issue by writing an Object launchpoint and added the child object from the object launchpoint when the parent object was added from integration( isinteractive==True). According to me, there is no point adding the child object to the json structure as the child object data is not sent from external system and you have to create the child object data from a script so creating that logic from object launchpoint should not be a problem.

    Still, One thing which I thought of as a solution but did not explore is this:
    1. Write the logic in beforeProcess(ctx) method in autoscript.
    2. Use the ctx.getData() to get the structure data.
    3. The use the structuredata.setcurrentdata() to set child object fields. This is supposed to add new tags into the payload.
    4. Then create a json mapping using json mapping application for the object structure to map the child object fields from step 3 into the child object fields. 

    Frankly, this might not work but it is worth a try.

    One more idea is you said you were able to add json tags by getting the json data using erdata.getDataasString() method so you can try to use step 4 above to map your updated json schema to child object fields in json mapping application.

    Please let me know how it goes. Also, wait for Steven Shull he might have a better way to do this.

    ------------------------------
    Biplab Choudhury
    Tata Consultancy Services
    ------------------------------



  • 5.  RE: Maximo Automation Script for Integration - JSON

    Posted 07-02-2020 09:24

    The children data issue makes sense. We haven't really utilized JSON on Enterprise Services as most of the inbound integrations we do are just object structures as the additional processing available on enterprise services weren't typically required.

    It doesn't seem like your use case really requires adjusting the message itself, so I would probably do this using an Object Structure inbound processing automation script instead. There are a couple of functions you can declare to manipulate the transaction depending on exactly what you need to do and when, but it seems like you should probably use the afterMboData or preSaveRules functions. You can access the JSON using ctx.data if you need to retrieve values from the message, but it's pretty easy to determine which object you are currently on (which is critical in this scenario if you have children objects) and then invoke additional logic. 

    def afterMboData(ctx):
        mbo = ctx.getMbo()
        if ctx.getProcessTable()=="PO":
            emxSet=mbo.getMboSet("EMXCUSTOMOBJECT")
            emxMbo=emxSet.add()
            emxMbo.setValue("ATTRIBUTE1","VALUE1")
            emxMbo.setValue("ATTRIBUTE2","VALUE2")


    ------------------------------
    Steven Shull
    Projetech
    ------------------------------