Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

I am getting org.mozilla.javascript.NativeArray@16e67ab error in work notes.

ritesh1
Tera Contributor

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);

 

1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

Hi @ritesh 

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

View solution in original post

5 REPLIES 5

I have selected Insert And Update only, but it's working only after updating something in the incident after a incident is created.

find_real_file.png