Hi Folks!
I'm trying to manipulate an inbound message using the "beforeProcess" in an automation script, but can't quite accomplish what I need -- hoping one of the brilliant people on here can assist :)
I've got an object structure that includes SR with TKSERVICEADDRESS as a child object. Here's the format of an inbound message...
{"externalrecid":"ABC12345",
"tkserviceaddress": [
{
"latitudey": 45.123,
"longitudex": -85.123,
"formattedaddress": "1234 MAIN ST"
}
]
}
I want to get the "formattedaddress" from the child object and use it to populate the "description" attribute on the main object so that it looks like this:
{"externalrecid":"ABC12345",
"description":"SR near 1234 MAIN ST",
"tkserviceaddress": [
{
"latitudey": 45.123,
"longitudex": -85.123,
"formattedaddress": "1234 MAIN ST"
}
]
}
I can add a description on the message as shown below. But I don't know the syntax to get in to the child object and get the value of "formattedaddress" so that I can use it in the SR description.
Any help is greatly appreciated!!
def beforeProcess(ctx):
struc = ctx.getData()
srDescrip = "SR" #need to get "formattedaddress" value and add it here
struc.setCurrentData("description",srDescrip)
Note, I've tried a few things shown below to get the value from formatted address, but none have worked...
struc.getCurrentData("formattedaddress")
struc.getCurrentData("tkserviceaddress")[0].("formattedaddress")
struc.getChildrenData() #didnt work because struc is json
Thanks,
------------------------------
Ryan Coghlin
------------------------------
#AssetandFacilitiesManagement#Maximo#MaximoIntegrationandScripting