How to make Close Notes and Resolution Code mandatory when resolving service request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 08:53 AM
I'm trying to use a Client Script to make the Close Notes and Resolution Code fields mandatory when the "Resolve Service Request" button is pressed. I've seen suggestions to use a UI policy however I don't think that would work because it relies on the state field to be changed. In my environment, when the 'Resolve Incident' button is pressed, it changes the state to resolved then highlights the required fields for resolve/close, however for service requests, the "Resolve Service Request" button does not change the state, so a UI policy based on the state field would not be triggered.
Anyway, I have adapted a script we have in place to make these fields mandatory for Incidents to work instead for service requests but it doesn't seem to work. I don't know if all my variables are correct for starters (ie. 'close_sc_request' and 'resolve_sc_request'), which may be the issue. But I'm also wondering if it's even being triggered based on the behaviour noted above.
Here's my code:
function onSubmit() {
var action = g_form.getActionName();
if (action != 'close_sc_request' && action != 'resolve_sc_request')
return;
// Close notes and Close code must be on the form
if (!g_form.hasField('close_notes') || !g_form.hasField('close_code'))
return;
var state = '6';
if (action == 'close_sc_request')
state = '7';
g_form.setValue('sc_request_state', state);
g_form.setValue('state', state);
g_form.setDisplay('close_notes', true);
g_form.setMandatory('close_notes', true);
g_form.setDisplay('close_code', true);
g_form.setMandatory('close_code', true);
if (g_form.getValue('close_notes') == '' || g_form.getValue('close_code') == '')
return false;
}
Maybe another solution is to script the "Resolve Service Request" button to change the state to resolved, which would then allow the use of a UI policy.
Any ideas?
- Labels:
-
Request Management
-
Service Desk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2022 05:48 AM
You need to code in the "Resolve Service Request" button. Use the below code which is used in resolve incident UI action .
UI policy/client script is not a perfect solution here.
Raghav
MVP 2023