Update Multiple recrods in incident table using business rules

Sridhar32
Tera Contributor

I want to update all 'state' 'new' records to 'Closed' using business rules. I have used below query and tried before,after business rules. But it did not update. Can any one help me Which type we have to use and check my code as well.

 

(function executeRule(current, previous /*null when async*/ ) {

    var inc = new GlideRecord('incident');
    inc.addQuery('state=1');

    inc.query();

    while (inc.next()) {

        inc.setValue('state',7);

        inc.setValue('close_code','User error');

        inc.setValue('close_notes','test');


        inc.setWorkflow(false);


        inc.autoSysFields(false);


        inc.update();
    }

})(current, previous);
0 REPLIES 0