Need to populate Field message with Child incident count in Parent incident in field message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 10:14 AM - edited 08-08-2023 09:43 PM
Hi Developers,
I have a requirement like,
I created one new field in INC form called "Resolution" field type is choice. It contains 'New' and 'Existing' choices. This field i am displaying only in parent incidents. When user select 'New' in parent incident, If that parent incident have child incidents still active need to dispaly field message as " You have active child incidents, please close the child INC before closing parent INC" -- This message i need to show. If all the child incidents are inactive it did not show any message. Can any one help on the script part.
Example: If we have 4 child incidents for parent record, Info Message should be "You have 4 active child incidents, please close the child INC's before closing parent INC"
Thanks,
Praveen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 09:41 PM
Hi @Bert_c1 ,
Thanks for your reply
I need to populate Number of active child incidents in the info message.
For example: You have 4 active child incidents, please close the child INC's before closing the parent INC
I need this functionlaity in Info Message. Could you please help me on that.
Thanks,
Praveen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2023 04:51 AM
Hi,
You will get count of child incident by using getRowCount and print this in info message as below:
var activeChildIncidentsCount = grChild.getRowCount();
var message = "You have " + activeChildIncidentsCount + " active child incident";
g_form.addInfoMessage(message);
Thanks,
Sanika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2023 02:07 PM
You can add a line as follows:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
// Return if 'new' is selected
if(newValue == 'new') // 'new' is the choice value for "New"
return;
// now check for active child incidents
var incr = new GlideRecord('incident');
incr.addQuery('parent', g_form.getUniqueValue());
incr.addQuery('active', true);
incr.query();
ver noRecords = incr.getRowCount();
if (incr.next()) {
alert("You have " + noRecords + " active child incidents, please close the child INC before closing parent INC");
}
}
I hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2023 06:26 PM
@praveen47 I got the above to work after changing the line reference to getRowCount() to
var noRecords = incr.rows.length;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 09:44 PM