
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2018 03:36 AM
Use case: when closing an INC X , other incidents with the same Short Description as an INC X should have appended a string to the work notes that INC X has been closed.
Issue: there are appended few entries to the work notes instead of one only.
Code:
(function executeRule(current,previous) {
var INCnumber = current.number;
var gr = new GlideRecord('incident');
gr.addQuery('active',true);
gr.addQuery('short_description','=',current.short_description);
//gr.addQuery('state',7);
gr.query();
while(gr.next()) {
gr.state.getValue(7);
gr.work_notes = "Please note that incident " +INCnumber+ " with the same Short Description has been closed";
gr.update();
}
} ) (current,previous);
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2018 08:06 PM
HI Sir,
Can you mark answer as correct and close this thread so that everyone can use it.
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2018 05:57 AM
Hi,
Use below code:
var INCnumber = current.number;
var gr = new GlideRecord('incident');
gr.addQuery('active',true);
gr.addQuery('sys_id','!=',current.sys_id);
gr.addQuery('short_description','=',current.short_description); //gr.addQuery('state',7);
gr.query();
while(gr.next()) {
gr.state.getValue(7); g
r.work_notes = "Please note that incident " +INCnumber+ " with the same Short Description has been closed"; gr.update();
}
Thanks,
Ashutosh Munot

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2018 09:49 AM
Thanks, Buddy. Is working well now.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2018 08:06 PM
HI Sir,
Can you mark answer as correct and close this thread so that everyone can use it.
Thanks,
Ashutosh