How to disable an UI action through Client Script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2023 08:08 AM
I have tried disabling the UI action in a onChange client script through the below code:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2023 08:15 AM - edited 11-19-2023 08:17 AM
@Ankita Mondal You will not be able to disable UI Action using setDisabled as no such method on g_form.setDisabled doesn't exist.
Following is the way you should disable the UI Action via script.
Create an onLoad script on the form where you would like to disable the UI Action.
//Disable the 'request_approval' button
var items = $$('BUTTON').each(function(item) {
if (item.innerHTML.indexOf('Request Approval') > -1) { //replace Request Approval with the name of your UI Action
item.disable();
}
});
Here is the end result.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2023 08:19 AM
So depending on a selection on the form you wish to hide an UI action?
setDisabled is for fields, so it's not going to work on an UI action.
I doubt there's any direct way for you to disable an UI action with g_form.
Here's an example from Servicenow on hiding a UI action
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0697296
I'll add what the resolution says in case the link ever breaks:
For our UI action name "test". In order to hide both the top and bottom UI actions. We need to input the following into the corresponding UI policy "Execute if True" and "Execute if False" fields.
Execute if True:
function onCondition() {
$j('[data-action-name=test]').show();
}
Execute if False:
function onCondition() {
$j('[data-action-name=test]').hide();
}