- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
When user opens any incident which has child incident then there should be message saying for assignee group members that "This incident is parent for INCXXXXXX", child incident needs to be resolved before resolving parent incident, how to implement this scenario?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Hi @vidishaagarwal5
Method 1 : Display BR with On Load Client Script
We can write display BR to check if current incident has any child incident. Store result in scratchpad object and access scratchpad in on load client script to show message accordingly.
Method 2 :On Load Client Script with GlideAjax
We can write onLoad Client SCript with GlideAjax and check if current incident has any child incidents in server side code.
let me know if you need Script!!
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Hi @vidishaagarwal5 ,
You can follow below to get the solution.
1) Create a Display business rule and use script below.
(function executeRule(current, previous /*, gs, script_include*/) {
g_scratchpad.showChildIncidentMessage = false;
// Check if the current user is a member of the incident's assignment group
if (!current.assignment_group.nil() && gs.getUser().isMemberOf(current.assignment_group)) {
var childIncidentNumbers = [];
var grChild = new GlideRecord('incident');
grChild.addQuery('parent_incident', current.getUniqueValue());
grChild.addQuery('state', 'NOT IN', '6,7,8'); //use state value as per your requirement
grChild.query();
while (grChild.next()) {
childIncidentNumbers.push(grChild.getValue('number'));
}
if (childIncidentNumbers.length > 0) {
g_scratchpad.showChildIncidentMessage = true;
g_scratchpad.childIncidentList = childIncidentNumbers.join(', ');
}
}
})(current, previous);
2) Create onLoad Client script on incident table and use below script.
function onLoad() {
// Check the scratchpad variable set by the display Business Rule
if (g_scratchpad.showChildIncidentMessage === true) {
// Build the dynamic message
var message = 'This incident is a parent for: ' + g_scratchpad.childIncidentList +
'. Child incident(s) need to be resolved before resolving this parent incident.';
// Display the message at the top of the form
g_form.addInfoMessage(message);
}
}
Regards,
Vishal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Sample Script :
Method 1: Display Business Rule + On Load Client Script
Display Business Rule (server-side)
-
Table:
incident -
When: display
-
Script:
(function executeRule(current, g_scratchpad) {
var childGR = new GlideRecord('incident');
childGR.addQuery('parent', current.sys_id);
childGR.addQuery('active', true);
childGR.query();
if (childGR.hasNext()) {
g_scratchpad.hasChild = true;
g_scratchpad.childNumber = childGR.number; // capture one example child INC
} else {
g_scratchpad.hasChild = false;
}
})(current, g_scratchpad);
On Load Client Script
-
UI Type: All
-
Script:
function onLoad() {
if (g_scratchpad.hasChild) {
var msg = "This incident is parent for " + g_scratchpad.childNumber +
". Child incident(s) must be resolved before closing the parent.";
g_form.addInfoMessage(msg);
}
}How it works:
The Display BR runs before the form loads and sets values in g_scratchpad. The client script reads them on load and shows the message.
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Hi @vidishaagarwal5 ,
You can follow below to get the solution.
1) Create a Display business rule and use script below.
(function executeRule(current, previous /*, gs, script_include*/) {
g_scratchpad.showChildIncidentMessage = false;
// Check if the current user is a member of the incident's assignment group
if (!current.assignment_group.nil() && gs.getUser().isMemberOf(current.assignment_group)) {
var childIncidentNumbers = [];
var grChild = new GlideRecord('incident');
grChild.addQuery('parent_incident', current.getUniqueValue());
grChild.addQuery('state', 'NOT IN', '6,7,8'); //use state value as per your requirement
grChild.query();
while (grChild.next()) {
childIncidentNumbers.push(grChild.getValue('number'));
}
if (childIncidentNumbers.length > 0) {
g_scratchpad.showChildIncidentMessage = true;
g_scratchpad.childIncidentList = childIncidentNumbers.join(', ');
}
}
})(current, previous);
2) Create onLoad Client script on incident table and use below script.
function onLoad() {
// Check the scratchpad variable set by the display Business Rule
if (g_scratchpad.showChildIncidentMessage === true) {
// Build the dynamic message
var message = 'This incident is a parent for: ' + g_scratchpad.childIncidentList +
'. Child incident(s) need to be resolved before resolving this parent incident.';
// Display the message at the top of the form
g_form.addInfoMessage(message);
}
}
Regards,
Vishal
