Prevent update via UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2024 06:44 AM
Hi, I'm trying to prevent incident submissions with short descriptions (less than 10 characters) using a UI Action script. I've created the script to show an error message and prevent submission, but it's not working as intended. When I click Submit, the incident still opens even if the description is too short.
I've tried using a Client Script, and that works correctly. Is there a way to achieve this using a UI Action?
Additionally, I'd like to add two empty lines after the error message within the same frame. Is this possible?
Any help would be greatly appreciated

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2024 10:46 AM
Hi @MarkNow ,
Can you share the UI Action scrript here???
you must use return false; if u r validation is in client side or use current.setAbortAction(true); if its in the Server side logic.
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2024 11:38 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2024 10:04 AM
Hi @MarkNow ,
There are erros in your code, here is the working code.
1)line number 2 - short_description.length < 10) --> this should be field.length<10
2)Line number 3 bracker is not closed
3)Return false is outside of the if block.
Here is the working code.
function onSubmit() {
var field = g_form.getValue('short_description');
if (field.length < 10) {
g_form.showFieldMsg('short_description', 'The title is too short (less than 10 characters).');
g_form.showFieldMsg('short_description', 'Please complete', 'error');
return false; // Prevent submission
}
}
Hope this helps!!!
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2024 11:29 AM
Hi @MarkNow ,
Please check below script this will help you
function onSubmit() {
var field = g_form.getValue('short_description');
if (field.length < 10) {
g_form.addErrorMessage('The title is too short (less than 10 characters');
g_form.addErrorMessage('Please complete');
return false; // Prevent submission
}
}
Result
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak