Resolve all button Issue

priya pretty
Tera Contributor

Hi Experts,

 

I have written the below code for resolving the records based on the Vulnerability. when ever I click on the resolve all button only that record is getting closed but not the other records. Can anyone help with this.

 

Thanks in advance

function onClickResolveall() {
    sn_vul.Modal.popupResolveAppItemModal();

    var relatedItems = new GlideRecord('sn_vul_app_vulnerable_item');
    relatedItems.addQuery('vulnerability', current.vulnerability);
    relatedItems.addEncodedQuery('active=true^stateIN1,2');
    relatedItems.query();

    while (relatedItems.next()) {
        relatedItems.state = 101; // Resolved state
        relatedItems.resolution_reason = current.resolution_reason;
        relatedItems.active = false;
        relatedItems.update();
    }
    action.setRedirectURL(current);
}

 

5 REPLIES 5

Are you getting multiple records using the query that you have in the gliderecord, try putting into gs.info logs to see if you finding multiple records in the query.

Best Regards
Aman Kumar