UI Action grayed out
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2017 11:15 AM
Hi I have created a UI action and apply the condition that when onclick it should be grayed out. But when I am reloading the form button again become visible.
I want it should be grayed out even after reload the form.
Please let me know how can I do this ?
UI action screenshot :-
UI Action button locked_out which needs to be hide :-
Thanks,
Sourabh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2017 11:34 AM
The way you have defined your UI action, you have to click the button for it to be disabled, which doesn't make a lot of sense. If you want the button to be disabled on form load, use an onLoad Client script instead.
Making UI actions disabled isn't a standard ServiceNow practice, you should take a look at using the Condition field in the UI action to say when the button should be visibl, versus using a client script to disable it. Using the client script has an additional drawback - your users could tell their browser to re-enable the button, and then they could click it anyway.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2017 11:54 AM
Hi Patrick
It is not like that. I have created a UI action Locked and when user click on it certain fields of form become grayed out and along with that this button should also disable. But when I am clicking the button required field and this button become grayed out. But when I am reloading the form then Locked button and other fields again come into editable mode.
I am using below script :-
function set(){
g_form.setReadOnly('u_tag', true);
g_form.setReadOnly('start_date', true);
g_form.setReadOnly('end_date', true);
g_form.setReadOnly('cost', true);
g_form.setReadOnly('budget_cost', true);
g_form.setReadOnly('u_tag', true);
g_form.setReadOnly('dependency', true);
g_form.setReadOnly('locked_out', true);
document.getElementById("locked_out").disabled = true;
}
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2017 12:06 PM
I think I see where you are going with this. Like I mentioned, if you want *anything* to happen when you load a form, you have to use an onLoad Client Script. You would create that client script, and tell it to make those fields and the UI action read only/disabled.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2017 12:07 AM
Hi Sourabh,
your main error is this: when you click that UI Action, you do not change anything in the data record being displayed in the form. And because there is no change in the underlying data, the form will load exactly the same way when you re-open or re-load the form. That is intended behavior - it has to be that way!
I assume that with your UI Action you want to mark (parts of) this record as locked (read-only). In order to achieve this, you will need to introduce a new field (e.g. 'locked', true/false) that you can use as a flag, and your UI Action can then set this field to true.
Then use a UI Policy to set all required fields to 'read-only' if the flag is set to 'true', and use the condition field of the UI Action as Patrick has mentioned above to hide the UI Action.
Kind regards
Ralf Schnell