Background script to update date field

ceraulo
Mega Guru

Hello!

I need to update the retirement date of assets with a specific date using background script. This is my script but it does not work.

var gr = new GlideRecord('clm_m2m_contract_asset');
gr.addEncodedQuery('<insert query>');
gr.query();
while (gr.next()) {
   gr.retirement_date = '2022-01-30';
   gr.setWorkflow(false);
   gr.update();
}

Please help!

Thanks.

5 REPLIES 5

@ceraulo 

Hope you are doing good.

Did my reply answer your question?

If my response helped you please mark it correct to close the question so that it benefits future readers as well.

Regards
Ankur

 

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