Is it possible to hide values in drop down field on the current form using business rule?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2016 09:21 AM
need to hide 1-critical value on Priority field using B.R. on current form for current user.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2016 09:22 AM
A business rule would not be the right method for this. A client script would be better tailored to show/hide choice list options. Consider using the method g_form.removeOption()
Reference:
Business Rules - ServiceNow Wiki
Business Rules Best Practices - ServiceNow Wiki
Client Scripts - ServiceNow Wiki
Client Script Best Practices - ServiceNow Wiki
GlideForm (g form) - ServiceNow WikiNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2016 11:24 AM
Let me know if I have answered your question. If so, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
If you are viewing this from the community inbox you will not see the correct answer button. If so, please review How to Mark Answers Correct From Inbox View.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2016 11:26 AM
still not working. is there any other way to check if user is not a member of group?
Doesn't work for:
function onLoad() {
//Type appropriate comment here, and begin script below
var currentuser = g_form.getValue('opened_by');
var groups = new GlideRecord('sys_user_grmember');
groups.addQuery('group.sys_id','!=','a4f101051315120069bebc62e144b04e');
// var isAdmin = g_user.hasRole('admin');
groups.addQuery('user', currentuser);
groups.query();
if(groups.next()){
g_form.removeOption('u_incident_impact','1 - Enterprise');
}
}
Works fine when i don't use the operator in addquery.
function onLoad() {
//Type appropriate comment here, and begin script below
var currentuser = g_form.getValue('opened_by');
var groups = new GlideRecord('sys_user_grmember');
groups.addQuery('group.sys_id','a4f101051315120069bebc62e144b04e');
// var isAdmin = g_user.hasRole('admin');
groups.addQuery('user', currentuser);
groups.query();
if(groups.next()){
g_form.removeOption('u_incident_impact','1 - Enterprise');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2016 11:38 AM
Hi Shalini,
Thank you for including additional details. The restriction to limit it to a specific group was not part of the original request.
If I understand your requirement, you want to remove the '1 - Enterprise' option from the u_incident_impact list if the user is NOT part of a specific group, correct?
Something to double check... the VALUE of your u_incident_impact field. This appears to be a label. Double check the VALUE by right clicking on the field label and selecting Show choice list.
If that is the case, you were very close try this...
Standard disclaimer: The following code is untested, requires review and potential modifications.
function onLoad() {
//Type appropriate comment here, and begin script below
var currentuser = g_form.getValue('opened_by');
var groups = new GlideRecord('sys_user_grmember');
groups.addQuery('group','a4f101051315120069bebc62e144b04e');
// var isAdmin = g_user.hasRole('admin');
groups.addQuery('user', currentuser);
groups.query();
// If you get a record, it means they belong to the group and can skip this next part
if (!groups.next()){
g_form.removeOption('u_incident_impact','1 - Enterprise'); // Make sure this is a value and not a label
}
}