Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Script make date 2 weeks ahd

Joshua Comeau
Kilo Sage

Looking into when the user submits the form and selects a due date 

 that it will auto populate the due date field on the SCTASK form 

 

Script:
task.due_date = current.variables.respond_by;

How to make this script make the date ahead by 2 weeks of the selected date

3 REPLIES 3

Shashank_18
Mega Guru

Hi @Joshua Comeau 

 

please use the below script, hope this will resolve your issues:

 

var gdt = new GlideDateTime(current.variables.respond_by);

gdt.addWeeks(2);

task.due_date = gdt.getDate();

 

Please mark the answer correct/ Helpful, if it resolve your issue.

Thanks !

Prasad Dhumal
Mega Sage

Hello Joshua,

You can use GlideDateTime object to manipulate date.

var selectedDueDate = new GlideDateTime(current.variables.respond_by);
var twoWeeksLater = selectedDueDate.addDays(14);
task.due_date = twoWeeksLater;

aditya174
Tera Guru

HI @Joshua Comeau 

You can use the following script: 

 

var dateAhead= new GlideDateTime(current.variables.respond_by);

dateAhead.addWeeks(2);

task.due_date = dateAhead.getDate();

 

Please mark this ans correct /helpful if it helps you solve your problem.