How to parse Ecc Queue payload XML
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2024 05:12 PM - edited 05-18-2024 06:41 PM
Hi All,
I have created BR in Scoped Application ,
In Business Rule : ECC Queue , After /insert
Please help me how to parse XML Payload, I want to parse data and push "" number, pcstatus, op "" into one array. we want to use those 3-fields values in other place
<results probe_time="1633" result_code="0">
<result>
<output>
[ { "number":"12345" , "pcstatus":"DRILL" , "op":"654" } ]
</output>
</result>
another payload , How to get seccode, secstatus, secid and errodetails of code, description.
<results probe_time="1633" result_code="0">
<result>
<output>
{ "seccode":"12345" , "secstatus":"DRILL" , "secid":"654", "errorDetails":[ {"code " :"4001", "description":"auth fail"} ] }
</output>
</result>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2024 06:57 PM
What is your issue? My script works fine. However you need basic understanding of JavaScript to adapt to your needs as I cannot do your work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2024 07:01 PM - edited 05-19-2024 07:02 PM
I have already coded which is giving right results. just expected suggestions on about if more than one nested arrays had come, how can handle.
apart of that nothing.
var _strXML = '<results probe_time="1633" result_code="0"> <result> <output> { "seccode":"12345" , "secstatus":"DRILL" , "secid":"654", "errorDetails":[ {"code" :"4001", "description":"auth fail"} ] }</output> </result></results>';
var _objXml = new global.XMLDocument(_strXML);
var _arrResults = JSON.parse(_objXml.getNodeText('//output').trim());
var seccode = _arrResults.seccode;
gs.info("seccode :" + seccode);
var detailsArray = _arrResults.errorDetails;
for (i = 0; i < detailsArray.length; i++) {
gs.info("Code: " + detailsArray[i].code +
"\nDescription: " + detailsArray[i].description);
}