- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2022 10:18 AM
I have written a business rule to get all the affected CI of an incident. But when I am trying to update the work notes with an array of affected CI's, I am getting org.mozilla.javascript.NativeArray@16e67ab.
Here is my code I'm using in Business Rule
(function executeRule(current, previous /*null when async*/ ) {
//gs.addInfoMessage('Calling from BR');
var myObj = new GlideRecord('task_ci');
var arr = [];
myObj.addQuery('task', current.sys_id);
myObj.query();
while (myObj.next()) {
gs.addInfoMessage("Affected CI List: " + myObj.ci_item.getDisplayValue());
arr.push((myObj.ci_item.getDisplayValue()).toString());
current.update();
}
current.work_notes = "Test";
current.work_notes = arr;
current.update();
})(current, previous);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2022 10:29 AM
Hi
Update your script as:
(function executeRule(current, previous /*null when async*/ ) {
//gs.addInfoMessage('Calling from BR');
var myObj = new GlideRecord('task_ci');
var arr = [];
myObj.addQuery('task', current.sys_id);
myObj.query();
while (myObj.next()) {
gs.addInfoMessage("Affected CI List: " + myObj.ci_item.getDisplayValue());
arr.push((myObj.ci_item.getDisplayValue());
}
current.work_notes = arr.toString();
})(current, previous);
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2022 10:27 AM
Never use current.update() in your BR
Remove current.update() and make your BR before update
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2022 10:29 AM
Hi
Update your script as:
(function executeRule(current, previous /*null when async*/ ) {
//gs.addInfoMessage('Calling from BR');
var myObj = new GlideRecord('task_ci');
var arr = [];
myObj.addQuery('task', current.sys_id);
myObj.query();
while (myObj.next()) {
gs.addInfoMessage("Affected CI List: " + myObj.ci_item.getDisplayValue());
arr.push((myObj.ci_item.getDisplayValue());
}
current.work_notes = arr.toString();
})(current, previous);
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 02:00 AM
Hi Aman, thanks for your help. Now I'm able to get the list of affected CI as an array in Incident's work notes. But the work notes is getting updated only when I modify anything in Incident, and then update the incident.
I want the work notes to be updated the moment I save the incident.
Can you help me in this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 02:02 AM
When is your BR running?
Mark Insert and Update checkbox in When to run section in the business rule
Aman Kumar