- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
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
6 hours ago
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
6 hours ago
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
5 hours ago
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
6 hours ago
you can create display business rule on your table with script like this
please enhance this as per your customer's requirement
(function executeRule(current, previous /*null on display*/) {
// 1st check if your current incident has any open child incidents
var childGR = new GlideRecord('incident');
childGR.addQuery('parent', current.sys_id);
childGR.addQuery('state', '!=', 6); // Assuming 6 = Resolved state
childGR.query();
if (childGR.hasNext()) {
// Now check if the logged in user is member of the assignment group of the parent incident
var userGroups = gs.getUser().getMyGroups();
if (userGroups && userGroups.indexOf(current.assignment_group.toString()) !== -1) {
// Now you can collect child incident numbers for message
var childIncidents = [];
while (childGR.next()) {
childIncidents.push(childGR.number.toString());
}
var message = "This incident is parent for child incident(s): " + childIncidents.join(", ") +
". Child incident(s) need to be resolved before resolving the parent incident.";
// Show info message on the form for assignee group members
gs.addInfoMessage(message);
}
}
})(current, previous);
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Thank you for marking my response as helpful.
As per new community feature you can mark multiple responses as correct.
💡 If my response helped, please mark it as correct ✅ as well so that this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
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
5 hours ago
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/
