- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2024 06:32 PM
I am creating a data stream actions with page pagination setup. I am running issues into the output display/ script parser step.
Here's an example of what the payload returns from the REST call:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2024 09:08 PM
Assuming your objectRecord is an object from within your Records array, your issue is that ApprovalRequests holds an array, not an object (see your JSON):
"ApprovalRequests": [ // <--- This square bracket means ApprovalRequests is an array
Arrays don't have properties like Approver on it, so when you access this, you get undefined, and when you subsequentially try and access UniqueName on this undefined value you get your error. So you need to index into the array to access the object, for example:
outputs.targetObject.approvalrequest = objectRecord.ApprovalRequests[0].Approver.UniqueName;
I imagine you'll need to change this in other places that you refer to ApprovalRequests otherwise you'll get undefined for those values.
Keep in mind that this is just a fix for the data you've shown. You should consider what happens when the ApprovalsRequests array has multiple objects if that can ever occur, or if the array might be empty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2024 08:56 PM
@Oscar Mateos Try this if works because you have to go through record and get first array object which is a jason and from there you can get approval required.
var records=output.targetObject.Records[0]:
var approvalRequest=records['ApprovalRequests'][0];
var approvalRequired=approvalRequests['approvalRequired'];
you can test this if works then this code can be minimised further.
hope this will help you,thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2024 09:08 PM
Assuming your objectRecord is an object from within your Records array, your issue is that ApprovalRequests holds an array, not an object (see your JSON):
"ApprovalRequests": [ // <--- This square bracket means ApprovalRequests is an array
Arrays don't have properties like Approver on it, so when you access this, you get undefined, and when you subsequentially try and access UniqueName on this undefined value you get your error. So you need to index into the array to access the object, for example:
outputs.targetObject.approvalrequest = objectRecord.ApprovalRequests[0].Approver.UniqueName;
I imagine you'll need to change this in other places that you refer to ApprovalRequests otherwise you'll get undefined for those values.
Keep in mind that this is just a fix for the data you've shown. You should consider what happens when the ApprovalsRequests array has multiple objects if that can ever occur, or if the array might be empty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 11:46 AM - edited 04-02-2024 11:47 AM
Thank you @Nick Parsons ! This worked and saved a lot of headaches. I am now getting the approver uniqueName.
I'm having pagination setup issues at the moment.
It does not require limit/offset.
The payload returns a PageToken:(example below)
Here's what I have in the pagination setup step(see image). In the rest step, I have a query parameter name "PageToken" and for the value I'm using the data pill pickers to get the pageToken variable in the pagination setup step.
In my execution details I'm only getting 1 page count even though I know I should be getting a couple of pages. Also I'm getting an empty pageToken in the execution details. Any Ideas what the issue could be?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 11:24 PM
Hey @Oscar Mateos I have another question that I noticed in your screenshots. Did you use the data stream action in an import set, if so, how did you resolve the approval request object in the transform map?