
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 02:46 AM
Dear SNC,
how can I add seconds with Gliderecord to an existing record?
Idea
var gr = new GlideRecord("incident");
gr.addQuery("sys_id", "9b8eb0c94f71f20022c92eff0310c222");
gr.query();
if (gr.next()) {
gr.overdue = gr.overdue.addSeconds(3600);
gr.update;
}
Thank you in advance,
Simon
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 03:10 AM
Try this code. This will work.
var gr = new GlideRecord("incident");
gr.addQuery("sys_id", "9b8eb0c94f71f20022c92eff0310c222");
gr.query();
if (gr.next()) {
var gdt = new GlideDateTime(gr.overdue);
gdt.addSeconds(3600);
gr.overdue = gdt;
gr.update;
}
Mark the comment as correct/helpful if it helps to solve the problem.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 02:51 AM
Try this
var x = new GlideDateTime(gr.overdue);
gs.log("x: " + x.getValue());
var y = new GlideDateTime(x);
gs.log("y: " + y.getValue());
y.addSeconds(3600);
gs.log("z: " + y.getValue());
Regards
Pranav

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 02:51 AM
Hi
check here:
Regards
Alberto

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 02:52 AM
Hi Simon,
Can you try below.
var gr = new GlideRecord("incident");
gr.addQuery("sys_id", "9b8eb0c94f71f20022c92eff0310c222");
gr.query();
if (gr.next()) {
var overdueis=new GlideDateTime(gr.overdue); //is overdue field correct. if custom it should be u_overdue
gr.overdue = overdueis.addSeconds(3600);
gr.update;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 03:10 AM
Try this code. This will work.
var gr = new GlideRecord("incident");
gr.addQuery("sys_id", "9b8eb0c94f71f20022c92eff0310c222");
gr.query();
if (gr.next()) {
var gdt = new GlideDateTime(gr.overdue);
gdt.addSeconds(3600);
gr.overdue = gdt;
gr.update;
}
Mark the comment as correct/helpful if it helps to solve the problem.