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.

Glide date time add seconds not working

Lewis Hancox
Kilo Contributor

find_real_file.png

Hi ive posted above my code that currently works and creates announcements as needed the issue I am having is trying to add extra time to a variable based of gliddatetime time this is what I need to happen 

 

get glide date-time > add 12 hours > apply variable to 'to' field on the announcement 

 

I have tried following the ServiceNow documentation with the example in seconds pictured below

find_real_file.png

not only doesn't this add the extra time to the variable it also stops the script from running for some reason 

andy help is appreciated.

 

thank you in advanced 

1 ACCEPTED SOLUTION

The gdt() part is on line 7 is wrong. Just use gdt. So no ().

Line 6 would be nicer to code GlideDate() with in front of it new. It will work technically without, though using new makes it more clear:

gr.setValue('from', new GlideDate());

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

6 REPLIES 6

Dubz
Mega Sage

I've tested that code snippet in a fix script on my PDI and it works correctly. Can you post up how you have implemented it in your code?

hi, David, this is how I have implemented it, im almost sure im making a simple mistake

 

find_real_file.png 

The gdt() part is on line 7 is wrong. Just use gdt. So no ().

Line 6 would be nicer to code GlideDate() with in front of it new. It will work technically without, though using new makes it more clear:

gr.setValue('from', new GlideDate());

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

thank you i knew it would be something simple that i couldn't see