- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2018 01:25 AM
Hi All,
I am trying to update a date/time field in a record using background script.
I am able to get the required time and everything but the field is not getting updated with the new time in the record. I have used gr.update() and gr.setForceUpdate() but the field shows the old value.
I am using the below script:
var gr= new GlideRecord('incident');
gr.addQuery('number','INC071439');
gr.query();
if(gr.next());{
gs.print('callback date is' + " " + gr.u_callback_date);
var actual_time= gr.u_callback_date.getDisplayValue();
var gdt = new GlideDateTime();
gdt.setValue( gr.u_callback_date.getDisplayValue());
gdt.addSeconds(05);
var new_time=gdt.getValue();
gs.log('new time is: '+new_time);
gs.log('Actual time is: '+ actual_time);
gr.update();
}
The logs come up fine but the field data remains the same in the record. Please assist me in this regard.
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2018 05:53 AM
Hello Vishnu,
Try this:
var gr= new GlideRecord('incident');
gr.addQuery('number','INC071439');
gr.query();
if(gr.next());{
gs.print('callback date is' + " " + gr.u_callback_date);
var actual_time= gr.u_callback_date.getDisplayValue();
var gdt = new GlideDateTime();
gdt.setValue( gr.u_callback_date.getDisplayValue());
gdt.addSeconds(05);
var new_time=gdt.getValue();
gs.log('new time is: '+new_time);
gs.log('Actual time is: '+ actual_time);
gr.setValue('u_callback_date', new_time);
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2018 05:53 AM
Hello Vishnu,
Try this:
var gr= new GlideRecord('incident');
gr.addQuery('number','INC071439');
gr.query();
if(gr.next());{
gs.print('callback date is' + " " + gr.u_callback_date);
var actual_time= gr.u_callback_date.getDisplayValue();
var gdt = new GlideDateTime();
gdt.setValue( gr.u_callback_date.getDisplayValue());
gdt.addSeconds(05);
var new_time=gdt.getValue();
gs.log('new time is: '+new_time);
gs.log('Actual time is: '+ actual_time);
gr.setValue('u_callback_date', new_time);
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2022 06:37 AM
Hi! Did you ever find a solution to this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2022 06:59 AM
Hello,
I think Vishnu was able to use my script. can you please have a look and let me know if that works for you.