Options
- 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.
Labels:
1 ACCEPTED SOLUTION
Options
- 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 🙂
Best Regards
Aman Kumar
Aman Kumar
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 03:26 AM
