We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Bulk close records with comments or worknotes

AmanPratapS7233
Tera Expert

Hi All,

 

I don't want to send email notifications and bulk close change records. Why is my fix script not updating the comments and worknotes ?

 

My code: - 

var chg = new GlideRecord('change_request');
chg.addEncodedQuery('<YOUR_ENCODED_QUERY>');
chg.query();

gs.info("Changes found: " + chg.getRowCount());

while (chg.next()) {

chg.setWorkflow(false);
chg.autoSysFields(false);

chg.state = 3;
chg.comments = "This change is bulk closed";

chg.work_notes = "This change is bulk closed";

chg.update();
}

1 REPLY 1

Ankur Bawiskar
Tera Patron

@AmanPratapS7233 

update as this

See if any data policy is blocking the closure

var chg = new GlideRecord('change_request');
chg.addEncodedQuery('<YOUR_ENCODED_QUERY>');
chg.query();

gs.info("Changes found: " + chg.getRowCount());

while (chg.next()) {
    chg.state = 3;
    chg.comments = "This change is bulk closed";
    chg.work_notes = "This change is bulk closed";
	chg.setUseEngines(false); // disable data policy if any
    chg.setWorkflow(false);
    chg.autoSysFields(false);

    chg.update();
}

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader