How to get number of records updated in fix script

mkader
Kilo Guru

Hello,

I have a simple fix script. After the update, I want to alert how many records were updated. How can I do this?

flagIncident();

function flagIncident() {
    var actIncGR= new GlideRecord('incident');
    actIncGR.addEncodedQuery('priority=4^sys_created_onONLast year@javascript:gs.beginningOfLastYear()@javascript:gs.endOfLastYear()');
    actIncGR.query();
    while (actIncGR.next()) {
        actIncGR.setWorkflow(false);
        actIncGR.autoSysFields(false);
        actIncGR.active = false;
        actIncGR.update();
    }
    
    gs.info("# of incident(s) updated: " + actIncGR.getRowCount()));

}

Does the below do what I need it to do?

There are thousands of records, so I do not want to BOG the system down and therefore am hesitant to try it.

Thanks

11 REPLIES 11

It should print the number of records that were found for that query.

I'm not getting anything when I execute the fix script

can you just run the following in a background script?

flagIncident();

function flagIncident() {
  var actIncGR = new GlideRecord("incident");
  actIncGR.addEncodedQuery("priority=4^sys_created_onONLast year@javascript:gs.beginningOfLastYear()@javascript:gs.endOfLastYear()");
  actIncGR.query();
  gs.info("# of incident(s) updated: " + actIncGR.getRowCount());
}

I don't get the info message at the top. I only get the output displayed after the fix script is ran

I was looking at the progress worker. Sorry my fault