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
------------------------------
Original Message:
Sent: 07-01-2020 23:22
From: Selvam Manohar
Subject: Maximo Automation Script for Integration - JSON
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
Original Message:
Sent: 07-01-2020 09:27
From: Steven Shull
Subject: Maximo Automation Script for Integration - JSON
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
Original Message:
Sent: 06-30-2020 04:02
From: Selvam Manohar
Subject: Maximo Automation Script for Integration - JSON
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
------------------------------