- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2023 05:26 PM
We are ending up with multiple incidents attached to changes via the caused_by field leading to more than one "master" ticket in the service desk.
I would like to put something in place that when the agents go to the caused_by field on the incident and search for a change number and select it then it would tell them if there are already other incidents that have had that same change number entered into the caused_by field and what those incident numbers are.
I cannot wrap my head around where to start with that one. Any ideas?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2023 11:06 PM
Hi Susan,
One of the best practice of achieve your solution is to make a Ajax call. Writing GlideRecord in client script is not a good practice in ServiceNow.
So write a function in a Script Include, follow below:
and then make a Ajax call using "OnChange" Client script.
The end result will be something like below:
Hope it helps and please mark helpful if it solves the issue.
Thanks,
Pooja Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2023 07:04 PM
hi Susan,
Seems a Client Script can do that, I tried a quick attempt, popups appear when a CHG is entered in the 'Caused by Change' field on incident. see screenshot:
Other means may exist depending on the desired user experience. The script logic above can be modified to show a single 'alert' with all incidents if desired.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2023 08:47 PM
This looks great - i changed it to a message as that's what higher ups want but i really like it.
Would love to know how to get all the related incidents showing if you already know how to do that?!
Thank you for taking the time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2023 09:39 PM - edited 07-16-2023 10:16 PM
Well.. I got it working in the UI with the list of incident tickets already linked to a change (if there are any)
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var IncChg = [];
var inc = new GlideRecord('incident');
//inc.addActiveQuery();
inc.addQuery('caused_by', newValue);
inc.query();
while (inc.next()) {
IncChg.push(inc.number);
}
if (IncChg.length >= 1)
{
alert("The following ticket(s) have already been opened as being caused by this change: " + IncChg); }
}
It doesn't however show up on the incident form on workspaces... *sigh* which is where it is needed most.
Can it be made to show on workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2023 11:06 PM
Hi Susan,
One of the best practice of achieve your solution is to make a Ajax call. Writing GlideRecord in client script is not a good practice in ServiceNow.
So write a function in a Script Include, follow below:
and then make a Ajax call using "OnChange" Client script.
The end result will be something like below:
Hope it helps and please mark helpful if it solves the issue.
Thanks,
Pooja Singh