RITM Fix Script Help!

Snow Angel
Tera Expert

Hello all,

I need to update multiple historical RITM records where field name is start_date (a variable on RITM)  on sc_req_item, the value of the field should be updated to 2020-10-21.  Please can someone help me to fix the below script.

*I have tried th ebelow but its not updating the variable which is btw greyed out/read only.
// Define the list of RITM numbers
var ritmNumbers = 'RITM0095731';
// Update the start_date field for the specified RITM numbers
var gr = new GlideRecord('sc_req_item');
gr.addQuery('number', 'IN', RITM0095731);
gr.query();

while (gr.next()) {
    gr.start_date = '2020-10-21';
    gr.update();
}

gs.info('start_date field updated for the specified RITMs.');

 

1 ACCEPTED SOLUTION

James Chun
Kilo Patron

Hi @Snow Angel,

 

Since it's a variable, you need to use the variables object.

Replace the following 

 gr.start_date = '2020-10-21';

 

with

 gr.variables.start_date = '2020-10-21';

 

Also make sure you have the speech marks around the number when you are querying by a number.

i.e. 

gr.addQuery('number''IN', 'RITM0095731');
 
Cheers

View solution in original post

5 REPLIES 5

James Chun
Kilo Patron

Hi @Snow Angel,

 

Since it's a variable, you need to use the variables object.

Replace the following 

 gr.start_date = '2020-10-21';

 

with

 gr.variables.start_date = '2020-10-21';

 

Also make sure you have the speech marks around the number when you are querying by a number.

i.e. 

gr.addQuery('number''IN', 'RITM0095731');
 
Cheers