Ankur Bawiskar
Tera Patron
Tera Patron

Many a times there comes a use-case to hide the List Context Menu which is created on Parent table to be hidden on Child table..

Example: "Assign to me" is List Context menu UI action on Task [task] table and would be present on Request [sc_request] table , Request Item [sc_req_item] as well. We would like to hide the UI action on Request table.

OOB the UI action condition is: gs.hasRole('itil')

If you try to update the UI action condition as below; such that it should not be shown when table is sc_request; it won't work.

gs.hasRole('itil') && current.sys_class_name != 'sc_request'

Note: Issue is current object does not work in List Context Menus and is ignored; So when you click the UI action it shows message as "Security does not allow the execution of that action against the specified record".

The script within the UI action won't execute but it shows that message.

https://hi.service-now.com/kb_view.do?sysparm_article=KB0725860

Workaround: In the UI action condition determine the URL and check whether the url contains the table sc_request or not

gs.hasRole('itil') && gs.action.getGlideURI().toString().indexOf('sc_request') == -1

So it would now hide the List Context UI Action on Request [sc_request] table; if you want to hide it for any other table as well you can enhance the condition to handle the table

Screenshots:

1) UI Action Condition:

find_real_file.png

2) UI Action Hidden on Request table:

find_real_file.png

3) UI Action visible on Task table:

find_real_file.png

Thanks for reading the blog and do provide your inputs/suggestions if any.

Hope you find this article helpful. Don’t forget to Mark it Helpful, Bookmark.
Thanks,
Ankur Bawiskar

ServiceNow MVP 2020,2019,2018

My Articles & Blogs

1 Comment