- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2022 01:17 AM
I have a requiremenet to Create a Business Rule that will output information about Incidents with the same Caller. When a new Incident is created, search the database for other Incidents that have the same value in the field Caller and use gs.addInfoMessage() method to display their Numbers at the top of the page.
Solved! Go to Solution.
- Labels:
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2022 01:48 AM
@lakshmi
Try this:
(function executeRule(current, previous /*null when async*/ ) {
var arr = [];
var grI = new GlideRecord("incident");
grI.addQuery("caller_id", current.getValue("caller_id"));
grI.addActiveQuery(); //use this to return active incidents
grI.query();
while (grI.next()) {
arr.push(grI.getValue("number"));
}
gs.addInfoMessage("Caller Incidents are:" + arr.toString());
})(current, previous);
Hope it helps
Thanks,
Murthy
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2022 01:41 AM
Please use this script in After Business Rule
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord('incident');
gr.addQuery('caller_id', current.caller_id);
gr.query();
while (gr.next())
{
gs.addInfoMessage(gr.number);
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2022 02:21 AM
Hi,
You do not need a script for this at all. Just add the related list as below and it will automatically do the job for you:
Right click on Incident Form Layout and then select Configure
-->Related List as shown below:
Now add the Related List :Incident by Same Caller" to the Right bucket and click on Save as shown below:
Result:
This will automatically calculate the Incident by same caller and show it to you rather than writing an additional script .
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2022 03:37 AM
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2022 03:38 AM
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2022 05:49 AM
Hi Lakshmi,
If you are doing for practice purpose then it is ok.
but if you are implementing in real-time you can suggest the approach to the business which is given by
Thanks,
Murthy
Murthy