- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2018 12:34 AM
Hi All,
Here i am trying to add 1 year and fetch result into u_next_verification_date. when i execute in the message it shows correct , but in the field value showing wrong.
Any help is highly appreciated.
Vass
When i update the record it is showing the correct date values in the message below.
But when i open the record and check the field value it showing wrong. (Highlighted field).
Also i wish the date value should be the blue rounded one hours/minutes/seconds.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2018 03:51 AM
Try Below Code,Its working fine
var gr = new GlideDateTime();
var gr1=gs.yearsAgo(-1);
var date= gr1.split(' ')[0];
var time=gr1.split(' ')[1];
var gd = new GlideDate();
gd.setValue(date);
date=gd.getByFormat('dd/MM/yyyy');
gr1=date+' '+time; //gr1 is your converted format
gs.addInfoMessage(gr1);
current.u_next_verification_date =gr1;
current.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2018 10:56 PM
Hi Ravi,
Sorry for the dalay. Of course it is working fine , but there is a 1 hour difference. But I don't mind, because I need to find the difference in days .
But I am trying to find the difference of No.Days between current timestamp and verification date and place it in Days Since Last audit field.
I am trying with below code in display business rule. I am getting wrong no . days. Is this also something you can help me?
(function executeRule(current, previous /*null when async*/) {
var gdt1 = new GlideDateTime(current.u_verification_date);
var gdt4 = new GlideDateTime(gdt1).getDate().getByFormat("dd-MM-yyyy");
gs.addInfoMessage('gdt4 = ' + gdt4);
var gdt2 = new GlideDateTime(gs.nowDateTime());
var gdt3 = new GlideDateTime(gdt2).getDate().getByFormat("dd-MM-yyyy");
//var gdt2 = new GlideDateTime().getDate().getByFormat("dd-MM-yyyy");
gs.addInfoMessage('gdt3 = ' + gdt3);
var dur = GlideDateTime.subtract(gdt2, gdt1); //the difference between gdt1 and gdt2
gs.addInfoMessage('dur = ' + dur);
var dur1= new GlideDuration();
gs.addInfoMessage('dur1 = ' + dur1);
dur1.setValue(dur.getValue());
g_scratchpad.dateTime = dur1.getDurationValue();
//current.<name of duration field>=dur1.getDurationValue();
gs.addInfoMessage('datetime = ' + g_scratchpad.dateTime);
//g_scratchpad.dateTime=gs.nowDateTime();
})(current, previous);
Got the below values:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2018 10:57 PM
Forgot to mention one more point here:
Once I get the duration value in scratchpad, I will assign the same in the field using a client script
Thanks
VASS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2018 11:01 PM
Apologies, please ignore the above script , sorry for the confusion
(function executeRule(current, previous /*null when async*/) {
var gdt1 = new GlideDateTime(current.u_verification_date);
gs.addInfoMessage('gdt1 = ' + gdt1);
var gdt2 = new GlideDateTime(gs.nowDateTime());
gs.addInfoMessage('gdt2 = ' + gdt2);
var dur = GlideDateTime.subtract(gdt2, gdt1); //the difference between gdt1 and gdt2
gs.addInfoMessage('dur = ' + dur);
var dur1= new GlideDuration();
gs.addInfoMessage('dur1 = ' + dur1);
dur1.setValue(dur.getValue());
g_scratchpad.dateTime = dur1.getDurationValue();
gs.addInfoMessage('datetime = ' + g_scratchpad.dateTime);
g_scratchpad.dateTime=gs.nowDateTime();
})(current, previous);
Thanks
VASS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2018 12:38 AM
Thanks Ravi and Archana for your continuous support and without you both I could not achieve this guys.
I got this working.
Regards,
VASS

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2018 02:03 AM
Glad to hear that 🙂