Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

concatenation string with additional characters in array of objects

gopijasti
Tera Contributor

In a ServiceNow Flow Designer Action script step, I have an array of objects and I want to concatenate the values of a specific field (e.g., ‘transactoionId’) into a single string. How can I do that?

 

end production should looks something like [111,222,333] ( all numbers are transactioId's present in a array of object as shown on the image below .. Thanks very much in advance 

gopijasti_0-1750444108627.png

 

1 ACCEPTED SOLUTION

Hello @gopijasti , For output, do this in script
 

outputs.concatenated = ids.join(",");

 

View solution in original post

7 REPLIES 7

Muhammad Salar
Giga Sage

Hello @gopijasti , What are the values present in transactionid, any example ?

hi , 

the input feeding will look something like below : 

[

transactionIds

{
"transactionId": 246202,
"typeOfRequest": "Add",
"priority": 0,
"tog": 16,
"employeeNumber": 909760,
"rule": "20",
"typeOfTimeOff": "V25-Vac 2025 Entitlement",
"length": "Full day",
"time": null,
"startDate": "8/5/25",
"startTimeHour": 0,
"startTimeMinute": 0,
"startTimePeriod": null,
"endTimeHour": 0,
"endTimeMinute": 0,
"endTimePeriod": null,
"isOverride": false
},
{
"transactionId": 246203,
"typeOfRequest": "Add",
"priority": 0,
"tog": 16,
"employeeNumber": 99760,
"rule": "206",
"typeOfTimeOff": "V25-Vac 2025 Entitlement",
"length": "Full day",
"time": null,
"startDate": "8/6/25",
"startTimeHour": 0,
"startTimeMinute": 0,
"startTimePeriod": null,
"endTimeHour": 0,
"endTimeMinute": 0,
"endTimePeriod": null,
"isOverride": false
},
{
"transactionId": 2464,
"typeOfRequest": "Add",
"priority": 0,
"tog": 16,
"employeeNumber": 99760,
"rule": "20256",
"typeOfTimeOff": "V25-Vac 2025 Entitlement",
"length": "Full day",
"time": null,
"startDate": "8/11/25",
"startTimeHour": 0,
"startTimeMinute": 0,
"startTimePeriod": null,
"endTimeHour": 0,
"endTimeMinute": 0,
"endTimePeriod": null,
"isOverride": false
}
]

Hello, @gopijasti try this

var parsedArray = inputs.parsedArray; // assuming this is passed as an input
    var ids = [];

    for (var i = 0; i < parsedArray.length; i++) {
        var obj = parsedArray[i];
        if (obj.transactionid) {
            ids.push(obj.transactionid);
        }
    }

    var concatenated = ids.join(",");

hi thank you,

i tried below and got null output . .

gopijasti_0-1750447596885.png

gopijasti_1-1750447614689.png

gopijasti_2-1750447642965.png