How to make suspend reasons mandatory on click of suspend button?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2025 03:22 AM
Requirement: For parent work order, suspended reasons field (sla_suspended_reason) should be mandatory at the time of clicking suspend button.
UI Action Script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2025 04:52 AM
Here are the steps
1) Make the UI action as client + server
2) in UI action check if comments is mandatory
3) inside the server side code use the code already given OOB
4) in workspace client script use GlideAjax and use the state model logic
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2025 05:00 AM - edited 02-03-2025 05:15 AM
something like this
function showSuspend() {
if (g_form.getValue('comments') == '') {
g_form.setMandatory('comments', true);
g_form.addErrorMessage("comments are mandatory");
return false;
}
gsftSubmit(null, g_form.getFormElement(), "work_order_suspend");
}
if (typeof window == 'undefined')
runServerCode(); //Server-side function
function runServerCode() {
if (current.work_notes != '') {
new StateFlow().processFlow(current, '7e82e738d7230100fceaa6859e61037d', 'manual');
}
}
Workspace client script
function onClick(g_form) {
if (g_form.getValue('comments') == '') {
g_form.setMandatory('comments', true);
g_form.addErrorMessage("comments are mandatory");
return false;
}
else{
// send sysid of record
var sysId = g_form.getUniqueValue();
// use GlideAjax and send this and query and use this line in server side code
// instead of current give that gliderecord object which you used to query the wm_order table with the sysId
// new StateFlow().processFlow(gr, '7e82e738d7230100fceaa6859e61037d', 'manual');
}
}
I hope I answered almost every detail of your question and you can take it from here based on developer skills.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2025 10:15 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2025 01:01 AM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader