Records not getting updated in List View

Reddymahesh
Tera Contributor

Currently , I have worked on a development where if service owner or service owner group has been changed on mapped application service table, It needs to be automatically updated in all the related incidents.

Issue is like only few records were seen getting updated on table list view not all.

 

Thanks. Below is the code for the BR I have used

 

(function executeRule(current, previous /*null when async*/ ) {
 
    var gr = new GlideRecord('incident');
    gr.addQuery('cmdb_ci', current.sys_id);
    gr.query();
    while (gr.next()) {
        gr.u_service_owner = current.managed_by;
        gr.u_service_owner_group = current.u_service_owner_group;
gr.update();
    }
 
})(current, previous);
21 REPLIES 21

Bert_c1
Kilo Patron

Hi,

 

Seems you may be affected by the use of "gr" in your script, please see:

 

Using gr in GlideRecord scripts

 

@Bert_c1 I looked code and there is no issues. 

But I don't see any changes to the object name "gr". Nor any use of 'debug' to track logic. Like:

 

(function executeRule(current, previous /*null when async*/ ) {
 
    var gr = new GlideRecord('incident');
    gr.addQuery('cmdb_ci', current.sys_id);
    gr.query();
    gs.info("BR Found " + gr.getRowCount() + " records to process.");
    while (gr.next()) {
        gs.info("BR Updating: " + gr.number);
        gr.u_service_owner = current.managed_by;
        gr.u_service_owner_group = current.u_service_owner_group;
        var updResult = gr.update();
        gs.info("BR Result form update: " + updResult);
    }
 
})(current, previous);

Reddymahesh
Tera Contributor

Any update on this