Flow Designer: Update List-Field on a record

Konstantinos Di
Mega Guru

Hey everyone,


I have a List-Field on the sys_user_group records which is a list of users.
I need to update this field via Flow to add a user while keeping those who are already in there and deleting one user while keeping the rest in.


I tried using the "Update Record"-Action but when adding a user to the list it completely overwrites the content and only adds that one user to it. When it comes to deleting only one specific user, I haven't found a way to do that in a flow.

 

Has anyone experienced that issue?
Thank you in advance,

Konstantinos

1 ACCEPTED SOLUTION

@Konstantinos Di 

 

I have created a custom List field called Users in Group table in my PDI and I created test flow for POC. 

 

The first action in the flow is Look Up record which returns a random user record and the second Action is a Look Up record which returns the Service Desk group record.

 

The third action is Update Record which updates the Users field with the user returned by the first action. See the script and screen shots below.

 

AnveshKumarM_3-1701853981286.png

var current_users = fd_data._2__look_up_record.record.u_users + '';
var new_user = fd_data._1__look_up_record.record.sys_id + '';
var updated_users = current_users + ',' + new_user;
return updated_users;

 

 

And I created another flow with same steps, but this time it deletes the user from the list without effecting others.

 

AnveshKumarM_4-1701854083368.png

 

var current_users = fd_data._2__look_up_record.record.u_users + '';
var del_user = fd_data._1__look_up_record.record.sys_id + '';
var updated_users = current_users.replace(del_user+',', "").replace(del_user, "");
return updated_users;

 

Service Desk Group before running any flow:

AnveshKumarM_0-1701853468599.png

 

Service Desk Group after running add flow:

 

AnveshKumarM_1-1701853499353.png

 

Service Desk Group after running delete flow:

 

AnveshKumarM_2-1701853726075.png

 

You can use the same logic in your case too.

 

Please mark my answer helpful and accept as a solution if it helped 👍✔️ 

Thanks,
Anvesh

View solution in original post

3 REPLIES 3

AnveshKumar M
Tera Sage
Tera Sage

Hi @Konstantinos Di 

The List field will contain sys_id of records separated by commas. If you wat to update, get the existing value and append the sys_id of the user and then set the updated value back to the field.

 

If you want to delete, remove the sys_id of user from the existing value and update the field with modified string.

 

Need more help! Let me know how you are getting the user to be added or deleted (Screenshots would be more helpful).

 

Please mark my answer helpful and accept as a solution if it helped 👍✔️

Thanks,
Anvesh

Hey Anvesh,
Is there a way to add and delete said specific user sys_Id without losing the lists content via Flow?
I don't have any kind of solution implemented to attach screenshots.

@Konstantinos Di 

 

I have created a custom List field called Users in Group table in my PDI and I created test flow for POC. 

 

The first action in the flow is Look Up record which returns a random user record and the second Action is a Look Up record which returns the Service Desk group record.

 

The third action is Update Record which updates the Users field with the user returned by the first action. See the script and screen shots below.

 

AnveshKumarM_3-1701853981286.png

var current_users = fd_data._2__look_up_record.record.u_users + '';
var new_user = fd_data._1__look_up_record.record.sys_id + '';
var updated_users = current_users + ',' + new_user;
return updated_users;

 

 

And I created another flow with same steps, but this time it deletes the user from the list without effecting others.

 

AnveshKumarM_4-1701854083368.png

 

var current_users = fd_data._2__look_up_record.record.u_users + '';
var del_user = fd_data._1__look_up_record.record.sys_id + '';
var updated_users = current_users.replace(del_user+',', "").replace(del_user, "");
return updated_users;

 

Service Desk Group before running any flow:

AnveshKumarM_0-1701853468599.png

 

Service Desk Group after running add flow:

 

AnveshKumarM_1-1701853499353.png

 

Service Desk Group after running delete flow:

 

AnveshKumarM_2-1701853726075.png

 

You can use the same logic in your case too.

 

Please mark my answer helpful and accept as a solution if it helped 👍✔️ 

Thanks,
Anvesh