- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 07:01 AM
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 09:24 AM
@Bjarne Nielsen completely agree 😉
CS + GlideAjax can get this one working.
Sample:
Client Script
function onLoad() {
var ga = new GlideAjax('MyIncidentUtils');
ga.addParam('sysparm_name', 'getReassignmentCount');
ga.addParam('sysparm_incidentID', g_form.getUniqueValue());
ga.getXMLAnswer(formLogic);
function formLogic(answer) {
var reassignmentCount = parseInt(answer);
g_form.addInfoMessage('Reassignment count: ' + reassignmentCount);
if (reassignmentCount > 2) {
g_form.addInfoMessage("Count is above 2 - make work_notes mandatory");
g_form.setMandatory("work_notes", true);
} else {
g_form.addInfoMessage("Count is 2 or less - do nothing");
}
}
}
Script Include
var MyIncidentUtils = Class.create();
MyIncidentUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getReassignmentCount: function() {
var incident = this.getParameter('sysparm_incidentID');
var gIncident = new GlideRecord('incident');
gIncident.get(incident);
return gIncident.reassignment_count;
},
type: 'MyIncidentUtils'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 10:39 AM
thank you so much.. it worked for me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 10:12 AM
You can use UI policy and also , you need to update Save UI action to make it mandatory before page load.
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 10:21 AM
HI @nishakumari1 ,
I trust you are doing great.
Here's a revised version of your script:
(function executeRule(current, previous /*null when async*/) {
// Check if the reassignment count is greater than 3
if (current.reassignment_count > 3) {
// Check if both work notes and comments are empty
if (current.work_notes.nil() && current.comments.nil()) {
// Inform the user that work notes or comments are required
gs.addErrorMessage('Please enter work notes or comments when changing the assignment group for incidents with a reassignment count greater than 3.');
// Abort the update to enforce adding notes or comments
current.setAbortAction(true);
}
}
})(current, previous);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi