Want to update Opened Date on Incident Record by Glide Record Update

SNOW46
Tera Contributor

Hi All,

I have one requirement to update one Incident Record Opened Date Field from 

"2018-12-20 20:37:44 3mo ago" to "2018-12-27 20:37:44 7d ago" via Glide Record Update.
Can anyone let me know how to glide the Incident Table and update the Record in the back end?
 
 
 
 
 
Thanks in advance..
 
 
1 ACCEPTED SOLUTION

Tarique2
Giga Contributor

you can run the below code in background script by adding your specific incident number and date value.

 

var gr=new GlideRecord('incident');
gr.addQuery('number', 'INC#####');
gr.query();
if(gr.next())
{
gr.opened_at='2018-12-27 20:37:44';
gr.update();
}

 

find_real_file.png

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

For this you can use fix script and query that record and update the field.

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Varsha21
Giga Guru

Hi,

 

you can use bellow kind of script,

var gr=new GlideRecord('incident');
gr.query();
while(gr.next())
{
gr.opened_at='"2018-12-27 20:37:44';
gr.update();
}

thanks

SNOW46
Tera Contributor

Hi Varsha,

Can you please let me know how it is going to work for a particular record and also for multiple records as well?

So that I can use the same script in background script right to fix this ?

 

Thanks...

Hi 

for particular record number like inc000003

var gr=new GlideRecord('incident');
gr.addQuery('number','INC0000003');
gr.query();
while(gr.next())
{
gr.opened_at='2018-12-27 20:37:44';
gr.update();
}

it will update it.

before that could you please elaborate it more so i will get idea about it.

var gr=new GlideRecord('incident');
//gr.addQuery('number','INC0000003');
//but if you want to for only created on "2018-12-20 20:37:44" then
gr.addQuery('opened_at','2018-12-20 20:37:44');
gr.query();//it will give all record which is having "2018-12-20 20:37:44" this date
while(gr.next())
{
//it will update all records which are opened at that day
gr.opened_at='2018-12-27 20:37:44';//with this value
gr.update();
}

for all record

thanks.