Fix Script to update all the existing RITMs Closed date

priyanka1028
Tera Contributor

Hi Team,

 

On requested items table records are closed complete but still closed date is not populated.

How can I write fix script to update all the existing records closed date by using updated date?

 

Please help me by providing your answer?

5 REPLIES 5

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Try this

 

var records = new GlideRecord('sc_req_item');
records.addQuery('state', 'closed_complete');
records.addQuery('closed_at ', '');
records.setWorkflow(false);
records.query();
while (records.next()) {
	records.closed_at = records.sys_updated_on;
	records.update();
}

 

-Anurag

 Thanks @Anurag Tripathi , But sys_updated_on fetching created on date not updated on date

How is that possible? Can you show a screenshot with RITM with created and updated fields and what you see when you run the script I gave.

-Anurag

Actually I got confused with dates it is populating updated date, But actually I want to update closed date by fetching ritms closed complete date and time.

That how can I do any idea do you have?