- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 07:21 AM
Hi everyone,
I have a requirement to hide a few request.states (not state) based on user role pm. Below are a couple client scripts I've attempted with no luck. The first script example is a copy of (BP) Hide Choice - Closed from incident table. Does anyone have any suggestions?
Thanks in advance for any feedback you can provide!
example 1
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 09:32 AM
It seems your are testing with admin user. To test whether the currently logged in user has the role "pm" explicitly assigned, use the hasRoleExactly() method
Please use below code and let me know,
Please mark my answer as helpful and accept it as the solution if it serves your purpose.
Thanks and Regards,
Krushna Birla
ServiceNow Consultant
LinkedIn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 08:42 AM
Hi @Gemma4
You have to use field name whenever you used getValue. Like, g_form.getValue(<field_name>);
In your case, it should be g_form.getValue('request_state');
Coming on to the point, to remove specific request state from choice field, you have to use removeOption method and add in conditional statement, Like
g_form. removeOption("<field_name>", "<option_to_be_removed>");
Here is your Solution:-
Please mark my answer as helpful and accept it as the solution if it serves your purpose.
Thanks and Regards,
Krushna Birla
ServiceNow Consultant
LinkedIn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 08:50 AM
I tried the following but it is removing closed skipped from all roles and not just pm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 09:32 AM
It seems your are testing with admin user. To test whether the currently logged in user has the role "pm" explicitly assigned, use the hasRoleExactly() method
Please use below code and let me know,
Please mark my answer as helpful and accept it as the solution if it serves your purpose.
Thanks and Regards,
Krushna Birla
ServiceNow Consultant
LinkedIn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 07:15 PM
Thank you so much. Using hasRoleExactly, resolved the issue. Appreciate all the feedback!