I am not able to update state value closed complete in HR record (multiple record)

chandan31
Tera Contributor

HI Sir,

 

I want to update multiple records in the HR case to closed complete but the script is not running , i am getting a correct getRowcount = 3 but it not working . I have used both update() and  updateMultiple().

 

var gr = new GlideRecord('sn_hr_core_case');
gr.addQuery('hr_service=9ecf515587f7019449e4c8cf8bbb35ea^state!=3')
gr.query();

while (gr.next()) {
    gs.info('chandan_test'+gr.getRowCount());
     
    gr.state = '3';
    gr.updateMultiple();
    }
 
 
Please advise

 

 
1 ACCEPTED SOLUTION

Hi @chandan31,

 

Semi-colon was missing at addQuery line. updated the scripts. please check and let me know.

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar

The world works with ServiceNow

View solution in original post

5 REPLIES 5

Sagar Pagar
Tera Patron

Hi @chandan31,

 

Try this updated scripts.

 

var gr = new GlideRecord('sn_hr_core_case');
gr.addQuery('hr_service=9ecf515587f7019449e4c8cf8bbb35ea^state!=3');
gr.query();

while (gr.next()) {
	gs.info('chandan_test' + gr.getRowCount());

	gr.state = '3'; // make sure value is correct
	gr.update();
}

 

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar

 

The world works with ServiceNow

In the Place addQuery it should be addEncodedQuery

 

Is it correct?

This script is not running.

Hi @chandan31,

 

Semi-colon was missing at addQuery line. updated the scripts. please check and let me know.

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar

The world works with ServiceNow