Data Stream (IntegrationHub) Action Output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2022 09:11 AM
I am using Data Stream (IntegrationHub) Data Source to import JSON data from a 3rd party site. I would like to use the response body directly as the action output, instead of creating and parsing each child item since there are many child items and some have complex data such as Array.Object. Göran Lundqvist mentioned in this youtube: https://www.youtube.com/watch?v=-lmbcm6j6Ew and I followed his suggestion (@ 55min). In Script Parser Step, I have
(function parse(inputs, outputs) {
- Labels:
-
Flow Designer
-
IntegrationHub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2025 03:32 AM
Solved my issue.
The inputs.sourceItem I was using contained keys/attributes that started with an underscore.
Even though I had created the correct Action output object with the leading underscores, ServiceNow would not pass this from the targetObject to the Output object.
I manually built the output object in the 'Script Parser step'
(function parse(inputs, outputs) {
var item = JSON.parse(inputs.sourceItem);
// Create PR object and add attributes
var prObj = {};
prObj.PurchaseRequisition = item.PurchaseRequisition;
// Create PR Item array
var prItemArray = []
for (var i in item._PurchaseRequisitionItem) {
// Create PR Item object and add attributes
var prItem = {};
prItem.PurchaseRequisition = item._PurchaseRequisitionItem[i].PurchaseRequisition;
prItem.PurchaseRequisitionItem = item._PurchaseRequisitionItem[i].PurchaseRequisitionItem;
prItem.PurchaseRequisitionItemText = item._PurchaseRequisitionItem[i].PurchaseRequisitionItemText;
prItemArray.push(prItem);
}
// Add the PR Item Array to the PR Object
prObj.PurchaseRequisitionItems = prItemArray;
outputs.targetObject = prObj;
})(inputs, outputs);
Hope this helps someone else.
Cheers Dan.
