Getting string value from an array.Object in Flow designer action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2024 12:36 AM
This is a response I get from an action in flow designer:
This is of the type array.Object
{ "Response": { "temporaryAttachments": [ { "fileName": "Requirement Analysis for Generic ID Creation CHG0092436.docx", "temporaryAttachmentId": "430a93eb-d1e7-4683-8b18-dd3c5731dd83" } ] } }
From this I want to fetch only the temporary attachment ID.
To achieve this I have created another action, which takes input as this from the previous action and given an inline script to fetch the ID from the .Object,
Script:
(function execute(inputs, outputs) {
// Input: array.object containing temporaryAttachments
// Output: string containing temporaryAttachmentId
// Check if the input is valid and contains temporaryAttachments
if (inputs && inputs.Response && inputs.Response.temporaryAttachments) {
// Get the first temporary attachment object
const tempAttachment = inputs.Response.temporaryAttachments[0];
// Check if the temporary attachment object exists
if (tempAttachment && tempAttachment.temporaryAttachmentId) {
// Return the temporary attachment ID as a string
outputs.attachmentId = tempAttachment.temporaryAttachmentId.toString();
} else {
outputs.errorMessage = "Temporary attachment ID not found.";
}
} else {
outputs.errorMessage = "Input does not contain temporary attachments.";
}
})(inputs, outputs);
I have defined the outputs also, although the execution shows successful, the attcahment ID is returing blank.
Kindly help me solve this, or a way to extract the ID from the object.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2024 02:41 AM
Ahh i think below is your issue.
in the output mapping Label is "attachmentId" but name is "attachmentid".
In the code you are using the label instead of the name which might be causing the output to not pass.
Please update and test.
If my answer helps you in any way please mark it as correct or helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2024 02:56 AM
Tried the same,
But still returning empty:
Still not sure why empty is returned, have tried most of the methods!
Kindly help,
Your assistance is very much appreciated!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2025 09:58 PM
You've shown the Action Inputs, but they're not expanded. Have you specified the structure of the object in the child configuration?
Also what about the Script Step input variables?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2025 12:18 AM - edited ‎05-09-2025 12:22 AM
Hello @Hussain Marakar ,
This worked for me. I tried to replicate the action in my PDI and did some tweaks as below :
Inputs : type changed to JSON
Script : Make sure you are using correct input parameter name :
(function execute(inputs, outputs) {
var jsonTempAttach = JSON.parse(inputs.parameter);
if (jsonTempAttach.Response.temporaryAttachments[0]) {
var tempAttachment = jsonTempAttach.Response.temporaryAttachments[0];
if (tempAttachment && tempAttachment.temporaryAttachmentId) {
outputs.attachmentid = tempAttachment.temporaryAttachmentId.toString();
} else {
outputs.errormessage = "Temporary attachment ID not found.";
}
} else {
outputs.errormessage = "Input does not contain temporary attachments.";
}
})(inputs, outputs);
Output :
If this solution helped resolve your issue, please consider marking it as helpful or correct.
This will assist others in finding the solution faster and close the thread.