Auto populate end date base on start date

Priti18
Tera Expert

hi all,

In my change request, i want to have my planned end auto populate based on start date with 5 days added. how can i do this?

 

 

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

Hello Priti,

If you want business days to add, then use schedules. Refer to this article where i have shown how to add business days.

https://community.servicenow.com/community?id=community_article&sys_id=df6464c9db1ed4909e691ea668961...

If you just wnat to add 5 days then in teh business rule

Before update

var startDate = new GlideDateTime(current.planned_start); //check field names
startDate.addDays(5);
current.planned_end=startDate;

Mark the comment as a correct answer and helpful if this helps to solve the problem.

View solution in original post

5 REPLIES 5

asifnoor
Kilo Patron

Hello Priti,

If you want business days to add, then use schedules. Refer to this article where i have shown how to add business days.

https://community.servicenow.com/community?id=community_article&sys_id=df6464c9db1ed4909e691ea668961...

If you just wnat to add 5 days then in teh business rule

Before update

var startDate = new GlideDateTime(current.planned_start); //check field names
startDate.addDays(5);
current.planned_end=startDate;

Mark the comment as a correct answer and helpful if this helps to solve the problem.

i have to add as per business days .....will check your link and let you know

i followed steps in the above link worked for me

 

thanks asif

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you should use before insert/update BR

condition: current.start_date != ''

Script:

(function executeRule(current, previous /*null when async*/) {

    // Add your code here

var gdt = new GlideDateTime(current.start_date);

gdt.addDays(5);

current.end_date = gdt;

})(current, previous);

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader