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

@sushantmalsure it is an After update business rule, Screenshot which I have attached is after commenting out Setworkflow(false) from the code

So you mean update of 'u_service_owner ' and 'u_service_owner_group' is still not happening?

Can you share the condition of BR when these fields needs to be updated and when BR gets executed?

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

@sushantmalsure below are the conditions 

Reddymahesh_0-1691091507441.png

 

and what is there in script section of this BR?

you are running the BR when values in these field changes and in script you are changing the value of same fields? 

Have this BR on Application Service table with conditions as 

managed_by CHANGES or u_service_owner_group CHANGES .
I hope these are 2 fields present on table and changing value in these 2 fields is the actual trigger point to update in related incidents.
In script of that BR you can use your script:

 

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

 

Do check u_service_owner  and u_service_owner_group field on incident are reference field same as the ones you are getting from.

 

 
 
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

@sushantmalsure I have verified these are same fields, referring to Service owner and service owner group on cmdb_ci_service_discovered table. We are not updating the same fields here if the service owner and service owner group are changed on cmdb_ci_service_discovered we are updating related incidents having this configuration item with the new values of service owner and service owner group.