- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2025 01:29 AM
When the state in problem form changes from new to any other state or from cancelled to any other state then work notes to be made mandatory. How to achieve this using UI policy as there is no changes option.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2025 08:29 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
‎04-02-2025 01:37 AM
for this you need to use onChange and you will know the earlier value(present in database) and the current value
OR
you can use before update business rule
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
if (current.state == 'cancelled' && previous.state == 'new' && current.work_notes == '') {
gs.addErrorMessage('Please fill work notes');
current.setAbortAction(true);
}
})(current, previous);
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
‎04-02-2025 01:40 AM
@Ankur Bawiskar i have tried with on change client script it works only one way, it wont work the reverse way
can you suggest using client script or UI policy rather going to BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2025 01:54 AM
you want work notes to be mandatory when
1) state changes from new to any
OR
2) state changes from Cancelled to any
try this and give correct state choice values
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Check if the state is changing from 'New' or 'Cancelled' to any other state
if ((oldValue == '1' && newValue != '1') || (oldValue == '7' && newValue != '7')) {
g_form.setMandatory('work_notes', true);
} else {
g_form.setMandatory('work_notes', false);
}
}
Also you can use business rule approach as shared by me earlier
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
‎04-02-2025 08:29 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