How to imitate mandatory like behavior on a field in UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 06:19 AM
Use Case:
I want to implement the mandatory behavior wherein after clicking the UI Action, after certain check if true it will highlight the field with red and sets the focus on that field.
I have tried:
if(condition == true) {
var field = g_form.getControl('field');
field.focus;
field.style.border = '1px solid red';
g_from.addErrorMessage('Error Message');
}
the field.focus will trigger the blue highlight on the field and it will be mixed with my field.style.border which is 1px solid red.
How to highlight it red and sets focus on that field.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 07:30 AM
Hi @ican
There was a typo error in your script.
You can create onClick() UI action and put below code under this -
function onClick(){
var field = g_form.getControl('short_description');
field.focus;
field.style.border = '1px solid red';
g_form.addErrorMessage('Error Message'); // typo g_from corrected to g_form
}
Output:
Hope this help you.
Regards
Moin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 07:42 AM
yes, its just a typo while i formulate this question.
but it is not like that in the actual code.
thanks for the reply though.
anyways i got this already.
i just defined the box shadow of that field then its all good.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 07:31 AM
Hi,
You can define field style for when the field values changes
Define field styles (servicenow.com)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 07:43 AM
thanks for the reply.
i got the solution to this already.
thanks.