- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2019 02:29 AM
Hi All,
I have one requirement to update one Incident Record Opened Date Field from
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2019 04:11 AM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2019 02:44 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2019 03:00 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2019 03:50 AM
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...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2019 03:56 AM
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.