Make Close Notes Mandatory when user click on Close Complete button on Agent Workspace and native view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2022 12:14 AM
Hi All,
There is OOB UI Action called Close Complete on sn_hr_core_case table: https://demoinstance.service-now.com/sys_ui_action.do?sys_id=ba5370019f22120047a2d126c42e701d&sysparm_view=&sysparm_domain=null&sysparm_domain_scope=null
I have made below changes in code to make close notes mandatory:
//Client-side 'onclick' function
function closecomplete() {
g_form.setMandatory('close_notes', true);
g_form.showFieldMsg('close_notes', 'Close notes are mandatory.', 'error');
return false; //Abort submission
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'closeComplete');
}
if (typeof window == 'undefined')
serverReopen();
function serverReopen() {
if (current.skip_automatic_user_acceptance_state)
current.state = 3;
else {
current.sla_suspended = true;
current.sla_suspended_on = new GlideDateTime().getDisplayValue();
current.state = 20;
}
current.update();
gs.setRedirect(current.getLink(true));
}
It is working at native view but not in agent workspace. Please advise.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2022 02:38 AM
Hi Rekha,
Please validate the below things and see if it fixes the issue -
1. Make sure the UI action is checked with the 'client' attribute to make it work with the client-side validation you have added
2. Validate the workspace form button is checked and has the below script.
3. If it still does not work, make sure the workspace client script is updated rightly, you can use the below as a reference
https://www.ashleysn.com/post/workspace-ui-actions
Thanks
-Harneet Sital (ServiceNow Certified Technical Architect)
Request you to please mark my answer as helpful or correct based on the impact
Find all my ServiceNow articles here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2022 07:40 AM
Hi
Thanks for response.
Yes client checkbox is checked and Workspace for, button is checked and script in workspace client script:
function onClick(g_form) {
g_form.submit(g_form.getActionName('closeComplete'));
g_form.setMandatory('close_notes', true);
g_form.showFieldMsg('close_notes', 'Close notes are mandatory.', 'error');
}
and Script in script field:
//Client-side 'onclick' function
function closecomplete() {
g_form.setMandatory('close_notes', true);
g_form.showFieldMsg('close_notes', 'Close notes are mandatory.', 'error');
return false; //Abort submission
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'closeComplete');
}
if (typeof window == 'undefined')
serverReopen();
function serverReopen() {
if (current.skip_automatic_user_acceptance_state)
current.state = 3;
else {
current.sla_suspended = true;
current.sla_suspended_on = new GlideDateTime().getDisplayValue();
current.state = 20;
}
current.update();
gs.setRedirect(current.getLink(true));
}
Still not working. Please advice further.