- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 04:51 AM
Hi All,
We have below requirement:
Whenever work notes / additional comments changes on the incident, it should get copied to all associated active incident tasks. Also when work notes of incident task changes it should get copied to the incident work notes. Also no notification should trigger from the record at which the work notes / additional comments are getting copied.
Thanks
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2020 11:00 PM
Hi Punit,
I believe you must be using business rule to trigger the REST/SOAP endpoint?
So basically you don't want to trigger API call when something updates from script but only when it is updated in some user' session?
If yes then you need to add this in the BR condition which triggers the API call
gs.getSession().isInteractive()
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 05:28 AM
Hi,
you would require business rule and avoid the loop by using setWorkflow(false)
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 05:33 AM
We are doing this with 2 after update business rule on the incident table, and 2 on the incident_task table. When Work notes changes and Updated by is not system (prevents recursion and unwanted system updates). The second rule is the same, but when Additional comments changes, though you might be able to combine these.
1) Copy Incident Work Notes to Active Incident Tasks
var inctask = new GlideRecord('incident_task');
inctask.addQuery('incident', current.sys_id);
inctask.addQuery('active', 'true');
inctask.query();
while(inctask.next()){
var curWN = current.work_notes.getJournalEntry(1); //gets the most recent work note
var curTN = current.number;
var curAG = current.assignment_group.name;
if(inctask.work_notes.getJournalEntry(1) == '' || curWN.indexOf(inctask.work_notes.getJournalEntry(1)) <0){
var newWN = curTN + " - assigned to " + curAG + "\n\n" + curWN;
inctask.work_notes = newWN;
inctask.update();
}
}
This appends the incident number and assignment group so that it's obvious it was copied, and checks to be sure it's not already there to prevent recursion with the business rule running on incident task
2) Copy Incident Task Work Notes to Incident
var inc = new GlideRecord('incident');
if(inc.get(current.incident.sys_id)){
var curWN = current.work_notes.getJournalEntry(1);
var curTN = current.number;
var curAG = current.assignment_group.name;
if(inc.work_notes.getJournalEntry(1) == '' || curWN.indexOf(inc.work_notes.getJournalEntry(1)) <0){
var newWN = curTN + " - assigned to " + curAG + "\n\n" + curWN;
inc.work_notes = newWN;
inc.update();
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 05:34 AM
Hello Punit,
Sample code here for reference https://community.servicenow.com/community?id=community_question&sys_id=00988ccbdb05b744fff8a345ca96...
- Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2020 12:02 AM
Thanks Ankur, Brad and Pradeep. It is working now.
However i have another requirement that when work notes/ additional comments get copied to incident task, we have a notification which triggers on update of work notes on incident task.
We want that notification to be triggered only when work notes on incident task is entered not in case of it is copied from incident. Also the same requirement is for incident as well.
I tried set workflow false however it do not work.
Thanks.