- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 03:50 AM
Hi Experts,
I have a requirement like I have created a record producer. The first variable is a select box in which I have added 4 choices. I want to hide some choices if a logged-in user belongs to a group.
How can I achieve this?
Let me know if anyone has done similar to this requirement.
Regards,
Amol
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 11:31 PM - edited 01-21-2024 11:33 PM
Hi All,
Thank you for your replies. I got the answer from the thread:
Script Include:
Thank you,
Amol
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 04:19 AM
Sorry mate, not an expert. Give try to @Ayushi12 solution.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 10:37 PM
Hi @Amol Pawar,
gs.getUser().isMemberOf does not work in SCOPED APPLICATION.
Please refer to the link:
gs.getUser().isMemberOf(current.assignment_group) not working
If I was able to solve your query, please mark my answer as correct and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 03:42 AM
Hi @Amol Pawar ,
You can use the below onload client script and script include.
1. Onload Client Script:
function onLoad() {
var grpmember = new GlideAjax('CheckuserGroup'); //script include name
grpmember.addParam('sysparm_name', 'getgroup'); //function name
grpmember.getXMLAnswer(getGroup);
function getGroup(response) {
if (response == 'true') {
g_form.removeOption(<fieldName>, <choiceValue>);
}
else { g_form.addOption(<fieldName>, <choiceValue>);
}
} 2. Script Include
var CheckuserGroup = Class.create();
CheckuserGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getgroup: function() {
var usersysid = gs.getuserId();//getting logged in usersysid
var mem = new GlideRecord("sys_user_grmember");
mem.addQuery('user', usersysid); //filtering current user
mem.addQuery('group',<add group sys_id>); //add group sysid
mem.query();
if (mem.next()) {
return true;
} else {
return false;
}
},
type: 'CheckuserGroup'
});Please mark my answer as helpful and correct if it helped.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 11:42 PM
Hi @Ankur Bawiskar,
Could you please help me with this? I read your answers on a similar thread. Can you explain here as well according to my scenario:
Thanks in advance,
Amol
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 02:39 AM
images are not visible.
what's your requirement?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
