Need to Storing Multiple Values from json comma seperated.

mdshahvez11
Tera Contributor

Hello everyone ,
I have a JOSN of watchlist users ,  in some case those can be multiple so i need to store there names and emails in a string type field ',' separated.

{
"size": 4,
"start": 0,
"limit": 50,
"isLastPage": true,
"_links": {
"self": "--------------------",
"base": "------------------",
"context": ""
},
"values": [
{
"accountId": "-----------------------------------------",
"emailAddress": "This 1",
"displayName": "This 2",
"active": true,
"timeZone": "Asia/Calcutta",
"_links": {
"Rest": "------------------------------",
"avatarUrls": {
"48x48": "------------------",
"24x24": "---------------------",
"16x16": "--------------------",
"32x32": "-------------"
},
"self": "------------------"
}
},
{
"accountId": "-------------------------",
"displayName": "This 3",
"active": true,
"timeZone": "Asia/Calcutta",
"_links": {
"jiraRest": "-----------------------",
"avatarUrls": {

}
}
]
}



like above JSON we have 2 display names
so I need to store them in one string field "," separated.
In my current flow I'm getting the last name of the participant , earlier one getting override.

mdshahvez11_0-1750190167188.png


Can anyone suggest me the correct way to achieve this.


1 ACCEPTED SOLUTION

Hristo Ivanov
Kilo Sage

 You can use the scripted option of the update step to concatenate the values, think something like

yourVariable += yourVariable

View solution in original post

5 REPLIES 5

Hristo Ivanov
Kilo Sage

 You can use the scripted option of the update step to concatenate the values, think something like

yourVariable += yourVariable

I tried something like this

 

(function transformWatchList(userString) {

    if (!userString) {

        return '';

    }

 

    var userNames = userString.split(',');

    var sysIds = [];

 

    var userGR = new GlideRecord('sys_user');

    for (var i = 0; i < userNames.length; i++) {

        var userName = userNames[i].trim();

        if (userName) {

            userGR.addQuery('user_name', userName);

            userGR.query();

            if (userGR.next()) {

                sysIds.push(userGR.sys_id.toString());

            }

        }

    }

 

    return sysIds.join(',');

})(inputs.user_string);

 

 

 

But that is not working as expected.

does it work at all or just partly?

mdshahvez11
Tera Contributor

@Hristo Ivanov thank you for the approach I had used flow var for the same.

 

Now there is one thing after getting the comma seperated users name / emails I want to add those names in case table watch list , but as the type is watch list how can I make sure to add single single participants in watchlist.

 

Using the flow while doing fields mapping .