- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 12:38 PM
I am working in Flow Designer and want to take the created date and add Data Pill which contains Days to it.
and add
contains (0, 30, 60, 120, 150)
I want to do this in a Flow Variable
Can this be done w/o scripting? What is the best way to accomplish this?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 01:07 PM
Hello,
For setting the flow variable via script, you'd click the script button at the end of the field and then create a GlideDateTime object, set the value using your date/time, then addDays with your other field value. Refer to documentation for overall approach: https://developer.servicenow.com/dev.do#!/reference/api/tokyo/server_legacy/c_GlideDateTimeAPI#r_GDT...
Example would roughly be:
var gdt = new GlideDateTime();
gdt.setValue(fd_data.walk_to_datetime_pill);
var num = Number(fd_data.walk_to_stringfield_that_has_number); //only need to use this if the number captured is in a string field instead of an integer
gdt.addDays(num);
return gdt.getDate(); //or use getValue() if you want the date and time
Please adjust the above as needed.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 12:48 PM
Hello,
You'd have to use script for this.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 12:50 PM
Allen,
Can you help me with the script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 01:07 PM
Hello,
For setting the flow variable via script, you'd click the script button at the end of the field and then create a GlideDateTime object, set the value using your date/time, then addDays with your other field value. Refer to documentation for overall approach: https://developer.servicenow.com/dev.do#!/reference/api/tokyo/server_legacy/c_GlideDateTimeAPI#r_GDT...
Example would roughly be:
var gdt = new GlideDateTime();
gdt.setValue(fd_data.walk_to_datetime_pill);
var num = Number(fd_data.walk_to_stringfield_that_has_number); //only need to use this if the number captured is in a string field instead of an integer
gdt.addDays(num);
return gdt.getDate(); //or use getValue() if you want the date and time
Please adjust the above as needed.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!