Hide an option in reference field based on user role on record producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2024 11:35 PM
Hi Team , I have a requirement to hide one option(ex: A) in reference field based on user role, for non-ITIL users option should not be visible on the form. Could you please help me on how to achieve this.
I have tried the on load script but its not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2024 02:41 AM
Hi @Ankur Bawiskar ,
I have tried the above script , it is filtering the only condition with users location , rest is not working. could you please help on this issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 03:47 AM
var tcc = new GlideAjax('script_Include_name');
tcc.addParam('sysparm_name', 'function');
tcc.addParam('sysparm_user', passYourValue);
tcc.getXML(callBack);
function callBack(response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
if (answer == 'true') {
g_form.removeOption('variable_name','variable_value','Variable Text');
}
var user = this.getParameter("sysparm_user");
var checkUser = new GlideRecord('sys_user_grmember');
checkUser.addQuery('user', user);
checkUser.addQuery('group', gs.getProperty('test')); // replace <sys_id_group> with actual sys_id of group.
checkUser.query();
if (checkUser.next()) {
return true;
} else {
return false;
}
If my response helped, please mark it as the accepted solution
Thanks
Jagadish