Populate End Date based on Start Date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2022 05:07 AM
Hello Guys,
I need to populate end date based on start date. on the form when we already have start date displayed. but when state changes I want end date to be auto populated with start date + 10days.
Below is the Before BR rule, I am using but no luck.
var sDate = new GlideDateTime(current.start_date);
sDate.addDays(10);
current.end_date= sDate;
Any help is appreciated.
Thanks,
Rocky.
- Labels:
-
Script Debugger
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2022 10:22 AM
Ohh.. my bad then.. it should work..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2022 10:35 AM
I think so.
Lets see if rocky tries and let us know.
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2022 05:17 AM
Hi Rocky,
Can you share what is the Field type of Start Date (Date or Date/Time) also what value are you getting in sDate variable.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2022 05:18 AM
Hi Anubhav,
Both start date and end date are of "Date" type.
Thanks,
Rocky.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2022 05:30 AM
Hi Rocky,
Try below:
var sDate = new GlideDateTime(current.start_date);
sDate.addDays(10);
var eDate = sDate.getDate();
current.end_date= eDate;
Also please put log for sDate and eDate so if you get any error let me know the values you get in both variables.
Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023