
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 11:32 AM
Hello guys,
I have a list type field in the department table that points to the user table. This list field can store more than one user sys id.
I need to check through a gr if any of that sys id is from the current user.
Thanks in advance.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 11:53 AM
Hi
Here is an example:
var departmentsGR = new GlideRecord('cmn_department');
departmentsGR.get('8898b18a3b700300d901655593efc4aa');
var currentUser = gs.getUserID();
gs.log(currentUser);
if(departmentsGR){
var userList = [];
userList.push(departmentsGR.u_users.getValue().toString());
gs.log(userList);
if(userList.indexOf(currentUser)){
gs.log('user found in list');
}
}
Replace 'u_users' with the field name for your user reference field
Tested and working in my PDI, let me know if you have any other questions.
Please mark my answer as Correct/Helpful based on impact
Regards,
Dan H

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 11:53 AM
Hi
Here is an example:
var departmentsGR = new GlideRecord('cmn_department');
departmentsGR.get('8898b18a3b700300d901655593efc4aa');
var currentUser = gs.getUserID();
gs.log(currentUser);
if(departmentsGR){
var userList = [];
userList.push(departmentsGR.u_users.getValue().toString());
gs.log(userList);
if(userList.indexOf(currentUser)){
gs.log('user found in list');
}
}
Replace 'u_users' with the field name for your user reference field
Tested and working in my PDI, let me know if you have any other questions.
Please mark my answer as Correct/Helpful based on impact
Regards,
Dan H

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 12:50 PM - edited 07-28-2023 12:51 PM
thank you brother, you helped me with an existential doubt because I had already thought about duplicates many times.