Make Justification field mandatory when change request is out of planned window
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2025 11:56 PM
Hi all,
When Change Request moving to implement and Review State,
if Actual Start Date < Planned Start Date ,
Actual Start Date < Planned End Date,
any one of this true then abort and throw error and make justification field mandatory and set state value to old value .
I have wrote the below on change of state client script . which is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2025 12:14 AM
Hello @Saranya K,
Use BR instead of onChange client script, use below logic:
Trigger: On update
Condition: When State changes to "Implement" or "Review"
if ((current.state == '-1' || current.state == '0') && (current.actual_start_date < current.planned_start_date || current.actual_start_date < current.planned_end_date)) {
// Abort update
gs.addErrorMessage("Actual Start Date cannot be before Planned Start or End Date. Please justify.");
// Make justification mandatory
g_form.setMandatory('justification_field', true);
current.setAbortAction(true); // Stops server-side update
}
Please mark my solution as Accepted and Helpful for future references.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2025 01:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2025 02:23 AM
g_form is a client-side API, and Business Rules run server-side. You cannot use g_form in Business Rules. If you want to make a field mandatory dynamically, you'd need to use a Client Script or UI Policy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @Saranya K
Are you not making justification mandatory at time of raising the change,if yes and value is already filled then how you can make it mandatory again? And if no, then it is not best practice while raising change you are not asking for justification.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************