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.

4 REPLIES 4

Rahul RJ
Giga Sage
Giga Sage

@Abhilasha G T You can do it using background script or fix script just need to update the sys_created_on field value.

Below is the sample code for the same

 

 

 var inc =new GlideRecord('incident');
    inc.get('sys_id','record_sys_id');
    inc.sys_created_on="Date_need_to_update";
    inc.autoSysFields(false);
    inc.setWorkflow(false); 
    inc.update();

 

 

 

Please mark the answer correct/helpful based on Impact.

 

Regards,

RJ

SatyakiBose
Mega Sage

Hello @Abhilasha G T 

You can do this by:

  • Exporting the XML version of the record.
  • Make the required changes
  • Import it back to the instance.

Take a look at the example below.

Here the created time for the company 3Com is 2005-05-24 06:44:46 AM

SatyakiBose_0-1678369486036.png

I exported the XML, and changed it to 26th

SatyakiBose_1-1678369533999.png

You will not be able to do it using a background script though.

 

If my response has solved your question, please mark it as a solution

 

 

Hi  SatyakiBose,

I tried , but its not working.

 

Regards,

Abhilasha G T

 

 

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);
   }