Issue with UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
My UI Action is not working in the workspace... can someone please guide what I need to write in the workspace client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
any update to this?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Sathwik1
Replace the code in the Workspace Client Script field (bottom box) with this:
function onClick(g_form) {
// 1. Clear previous error messages
g_form.hideFieldMsg('close_notes');
g_form.hideFieldMsg('resolution_code');
var isValid = true;
if (g_form.hasField('resolution_code') && g_form.getValue('resolution_code') == "") {
g_form.showFieldMsg('resolution_code', 'Resolution code is required.', 'error');
isValid = false;
}
if (g_form.hasField('close_notes') && g_form.getValue('close_notes') == "") {
g_form.showFieldMsg('close_notes', 'Resolution notes are required.', 'error');
isValid = false;
}
if (!isValid) {
g_form.addErrorMessage('To close a case, you must select a resolution code and add resolution notes.');
return; // This stops the submit from happening
}
g_form.submit('resolve_case');
}
not need to change the Server Side code (lines 19+ in your screenshot). Once g_form.submit() runs successfully, it will trigger that server code automatically.
Happy to help!
To help others in the community find this solution, kindly mark this response as the Correct Answer and Helpful.
Warm Regards,
Deepak Sharma
Community Rising Star 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Return should not be used in the client side.. it blocks some other OOB UI Action.
Open the respective table.. and from form header. right click on it.. it wont work.
