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.

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

Hi 

Use gr.addQuery("sys_id","your incident sys_id") and it will work for 1 record.

 

Hi,

Any updates?

you can use this code in background script as well as in fix script.

advantage with doing fix script is , we can capture script into update set and move to test and production instance.

thanks,

SNOW46
Tera Contributor

Hi Varsha,

Thanks for your quick help. It really worked for me. Thanks a lot....

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