Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Need to change the created date for the incident.

Abhilasha G T
Tera Contributor

 

I need to change the created date for the incident. Is it possible.

 

Example- INC0145485 created  2023-03-09 need to change it to 2023-03-08.

 

How to achieve this.

5 REPLIES 5

Amit Kumar Saho
Tera Contributor

Background Script for testing:

   

   var Id= 'sys_id'; // Replace with the actual sys_id
   var newCreatedDate = new GlideDateTime(); // Set this to your desired date
   newCreatedDate.setDisplayValue('2023-09-01 10:00:00'); // Change to your desired date and time

   var gr = new GlideRecord('Table Name');
   if (gr.get(Id)) {
   gr.sys_created_on = newCreatedDate; // Change the created date
   gr.update(); // Save the changes
   gs.print('Created date updated successfully to: ' + gr.sys_created_on);
   } else {
   gs.print('Incident not found: ' + Id);
   }