Issue with Flow and Custom Action (invalid return type: com.snc.cobject.ComplexObject)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2022 09:49 AM
I'm facing an issue with a Flow (REST API - Asynchronous) and custom Action (Script Step).
The Script Step return this error: invalid return type: com.snc.cobject.ComplexObject only if the Action is used in a Flow. If the Action is tested by it self it runs perfectly. Below are some screenshots.
1) REST API Trigger
2) Data from REST API Trigger:
3) The events (Array.Object) is used as input of the custom Action:
4) Here is the Action Input:
5) Here is the Script Step with Input Variables, Script and Output Variables
(function execute(inputs, outputs) {
var payloadsArray = [];
var i = 0;
for(event_idx in inputs.events) {
// Create empty payload object
var payloadObject = {}
payloadObject.policy_id = inputs.events[event_idx].payload.policy_id
payloadObject.policy_name = inputs.events[event_idx].payload.policy_name;
payloadObject.policy_condition = inputs.events[event_idx].payload.policy_condition;
payloadObject.policy_description = inputs.events[event_idx].payload.policy_description;
payloadsArray[i] = payloadObject;
i += 1;
}
outputs.payloads = payloadsArray;
})(inputs, outputs);
6) Here are the outputs:
If the Action is tested isolated, it works just fine:
But if it triggered using REST API Trigger, it fails with the mentioned error:
Can I get some help?
Thanks
- Labels:
-
Flow Designer
-
IntegrationHub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 01:46 AM
Sorry if this isn't any help but i recall having similar issue with Array object from Script action - never got it to work.
I had to output a string field (comma separated or any other) which i had to script into field or whereever it was going 😉
i tried quite a few different scenarios but none of them wouldn't want to work!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 02:02 AM
Hello Joao,
Could you please replace the for loop inside your custom action to below as it is missing var and check once if it works
for(event_idx in inputs.events) {
to this
for(var event_idx in inputs.events) {
// Create empty payload object
var payloadObject = {}
payloadObject.policy_id = inputs.events[event_idx].payload.policy_id
payloadObject.policy_name = inputs.events[event_idx].payload.policy_name;
payloadObject.policy_condition = inputs.events[event_idx].payload.policy_condition;
payloadObject.policy_description = inputs.events[event_idx].payload.policy_description;
payloadsArray[i] = payloadObject;
i += 1;
}
Please mark my respsone as helpful/correct, if it answer your question.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 11:12 PM
Actually now as looking more throughly there seems to be missing the POLICY from the object?
You assing the outputs.payloads:
var payloadObject = {}
payloadObject.policy_id = inputs.events[event_idx].payload.policy_id
payloadObject.policy_name = inputs.events[event_idx].payload.policy_name;
payloadObject.policy_condition = inputs.events[event_idx].payload.policy_condition;
payloadObject.policy_description = inputs.events[event_idx].payload.policy_description;
payloadsArray[i] = payloadObject;
i += 1;
}
outputs.payloads = payloadsArray;
but you try to get Policy out of it while handling the outputs after script.
Should you leave the POLICY level out and just define the object parameters straight after payloads ?
Jake
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2023 07:31 PM
Were you able to get this working?