Populate End Date based on Start Date

Rocky5
Kilo Sage

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.

11 REPLIES 11

Ohh.. my bad then.. it should work..

I think so.

Lets see if rocky tries and let us know.


***Mark Correct or Helpful if it helps.***

AnubhavRitolia
Mega Sage
Mega Sage

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. 

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

Hi Anubhav,

Both start date and end date are of "Date" type.

Thanks,

Rocky.

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.

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