Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to add list values in a Flow Designer variable

sattar3
Tera Contributor

Hello All,

 

In flow designer i created a set a flow variable, Please check the attached screenshot.

sattar3_0-1721806920107.png

Flow variable script:

var gr  = new GlideRecord("sys_user_delegate");

gr.addQuery('sys_id',fd_data._1__get_catalog_variables.u_delegate);
gr.query();
if(gr.next())
{
    return gr.sys_id;
}
and calling that in update of record, please check the screenshot.
sattar3_1-1721807372826.png

We are setting the selected delegate "end time" as current time. so that the selected delegation will end immediately with current time, which is working.

Previously it a reference type variable, now we changed to List collector type so that we can select multiple users in it.
I updated the script in flow set variable but it is not working for multiple delegates canceling but its working for 1 user.
Getting the below error in flow designer.
sattar3_2-1721807818230.png

Can someone please help me on this so that it will work for multi selected delegates cancellation.

 

@Ankur Bawiskar @Community Alums @Sid_Takali 

 

Thanks,
Sattar
3 REPLIES 3

RAMANA MURTHY G
Mega Sage

Hello @sattar3 ,

Can you attach the updated script for set Flow variable? then anyone can able to answer

 

Please mark my answer helpful  & correct if it helps you
Thank you

G Ramana Murthy
ServiceNow Developer

@RAMANA MURTHY G  Thanks for the reply.

I used the below script for list collector variable type.

 

var delegateSysIds = [];
var gr = new GlideRecord("sys_user_delegate");

// Assuming fd_data.1_get_catalog_variables.your_delegate is an array of sys_ids
var selectedDelegates = fd_data.1_get_catalog_variables.u_delegate;

for (var i = 0; i < selectedDelegates.length; i++) {
gr.addQuery('sys_id', selectedDelegates[i]);
gr.query();
if (gr.next()) {
delegateSysIds.push(gr.sys_id.toString());
}
}

// Return the list of sys_ids
return delegateSysIds;

 

I got the attached error "Value of field record is not a GlideRecord".

Flow error.png

Thanks,

Sattar

Hello @sattar3 ,

in this case you have to create Update Record action in for each flow logic

Please mark my answer helpful  & correct if it helps you
Thank you

G Ramana Murthy
ServiceNow Developer