- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 12:30 PM
Hello all,
I have created a custom field on change request form, "CAB Approvers".
So, using a business rule when the state moves to Cab review, I am populating the approval groups sys_ids into that custom field.
Now, I want to check if the logged in user is member of one of those groups, in client script.
Can someone please give me script how to achieve this?
Regards,
Lucky
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 02:20 PM
Please try this:
var arrGroups = current.CUSTOM_FIELD.toString().split(","); //Replace CUSTOM_FIELD with your custom field name
for (var i = 0; i < arrGroups.length; i++) {
var group = arrGroups[i].trim();
if (gs.getUser().isMemberOf(group)) {
g_scratchpad.memberofcab = "true";
return;
}
}
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 12:53 PM
Hi @Lucky1,
You can have a display business rule and set scratchpad object in there which you can access on your client script. (You don’t need a custom field for that)
if(gs.getUser().isMemberOf(YOUR_GROUP_NAME)){
g_scratchpad.memberofcab = “true”
}
then on you Client Script:
you can access your scratchpad object
var isMemberOfCab = g_scratchpad.memberofcap;
if(isMemberOfCab){
//Your logic
}
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 01:01 PM
Hello @Lucky1
You cannot directly interact with server using the client script. You either need GlideAjax or need to use the g_scratchpad object via Display Business rule to pass whatever value you need.
g_scratchpad.VARIABLE = VALUE
You can access this in client script in the same way.
Kindly mark my answer as helpful and accept solution if it helped you in anyway,
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 02:12 PM
Hello Shivalika and Medi,
Thanks for your reply.
In the Display BR, I am getting the value of my custom field value.
It is displaying 4 sys_ids of 4 different groups with comma separated.
Now in the scratchpad variable, I need to store the value after checking if the user is member of any of those 4 groups. How can I do that in script?
can you please help me?
Regards,
Lucky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 02:20 PM
If you want to communicate back-and-forth with the form, you'll need to use GlideAjax.
Alternatively, if you knew the groups to check prior to the form loading, you could use the display BR to look up the user in the sys_user_grmember table against each group.