- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2022 09:52 AM
Hii All,
I have written script like this,
when to run - after update
condition - work notes changes
script -
var inc = new GlideRecord('incident_task');
inc.addQuery('incident.sys_id', current.sys_id);
inc.query();
while (inc.next()) {
inc.work_notes = current.work_notes.getJournalEntry(1);
inc.update();
}
my script is not working but in place of worknotes if i place comments then it is working.
i don't know why it is happening like that.
please help me where i have written mistake here.
Solved! Go to Solution.
- Labels:
-
Multiple Versions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2022 11:48 AM
Hi Anji,
I just tested again and it is working:
If this answer is helpful please mark correct and helpful!
Regards,
Christopher Perry
Regards,
Chris Perry

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2022 10:43 PM
Hello
Can You Please try below code:- before/update
var grInc= new GlideRecord('incident_task');
if(grInc.get('incident',current.getUniqueValue()))
{
grInc.work_notes=current.work_notes.getJournalEntry(1);
grInc.update();
}
Mark my Response as Correct or Helpful, if you find it Appropriate.
Gaurav Shirsat : ServiceNow Community MVP 2022
https://www.linkedin.com/in/gauravshirsat/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2022 11:56 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2022 08:46 AM
Hello
Could You Please Check is there any other business rule working in your system?
Try to add script debugger in your script.
I tried in my PDI. it is working.
Can You Debug the Script by below using below screenshot:-
Click on the 1st line of code as stated below:
click on the icon mentioned and check one by one, is there any BR with current.update();
Mark my Response as Correct or Helpful, if you find it Appropriate.
Gaurav Shirsat : ServiceNow Community MVP 2022
https://www.linkedin.com/in/gauravshirsat/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2022 11:54 PM
Hi,
Try Before Update BR with below details.
Table: Incident
Before Update
When Worknotes Changes
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var grIncTask = new GlideRecord('u_incident_task');
//grIncTask.addQuery('u_incident',current.sys_id);
grIncTask.addEncodedQuery('u_incident='+current.sys_id+'^stateNOT IN5,6');
grIncTask.addActiveQuery();
grIncTask.query();
while(grIncTask.next())
{
grIncTask.work_notes = current.work_notes;
grIncTask.update();
}
})(current, previous);
//Update the query accordingly.
Thanks,
Sumit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2022 12:07 AM