How to update the created date ,2 days ago

Rajababu
Giga Guru

How to update the created date ,by past 2 days ago from current date on incident .

For example if incident0123  created 23-03-2021 - 2 days  =incident0123 created 21-03-2021

How to achieve this.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Rajababu 

you can use this script to set the Created Date/Time 2 days from it's current Created Date/Time

var inc = new GlideRecord('incident');

inc.addQuery('number', 'INC001');

inc.query();

if(inc.next()){

var gdt = new GlideDateTime(inc.sys_created_on);

gdt.addDaysUTC(-2);

inc.sys_created_on = gdt;

inc.autoSysFields(false);

inc.setWorkflow(false);

inc.update();

}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Hi,

So are you saying the script is working for admin but not for non-admin

can you share where have you written this script?

share the configuration screenshot as well

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Mark Roethof
Tera Patron
Tera Patron

Hi there,

When and where should this happen exactly? Is this a one time thing with background script? Or is it somewhere in your proces? Or within a workflow?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

No they want when there is such kind of scenario it execute.

But We are stuck how to update the incident created by me and update days back -sys_created_on field.