Mandatory comment on an incident state change
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 09:30 AM
Hello All,
I have a requirement to do the following on an Incident:
I am mandated to update the Additional Comments field when:
- I move an Incident into Cancelled state
- I move an Incident from On hold into In Progress state for On hold reason Awaiting Caller
- I move an Incident from Resolved to In Progress
I have setup a client script for this on change of state field. Below is my code:
The problem I have is that when I change the value in the state field, it is not making the comments field mandatory on first change. It does on 2nd change, but not on the first.
Anyone know how to make this work?
Many Thanks,
Luke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 11:13 AM
I would suggest using UI policy, which is much easier to manage.
Or try adding quotes while comparing and try below script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
g_form.setMandatory('comments', false); // Keep comments non-mandatory initially
// Check if moving to Cancelled state
if (newValue == "8") {
g_form.setMandatory('comments', true);
}
// Check if moving from On Hold to In Progress with On Hold reason Awaiting Caller
else if (oldValue == "3" && newValue == "2" && g_form.getValue('on_hold_reason') == "1") {
g_form.setMandatory('comments', true);
}
// Check if moving from Resolved to In Progress
else if (oldValue == "6" && newValue == "2") {
g_form.setMandatory('comments', true);
}
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 12:09 PM
I did think of this, but how would you manage an on change state in a UI policy?
Thanks for the comment, I will try the script :).