Copy link to clipboard
Copied
I know this question has been asked many times. I have followed so many scripts and I keep running into the same issue and cannot figure out why.
I have a date field that will be user entered. I need a 2nd field to calcuate 14 days from that date.
The issue that I am having is when i add the script (any that I have tired) the 2nd field calculates 14 days from TODAY. even when I enter a new date in the User entered date field the calculate field will not change.
Very frustrating! (Note I am Not a coder this is new to me... pls be kind) I hope someone can help!
Copy link to clipboard
Copied
Which field is your script in and what type of script (calculation/validation)?
Copy link to clipboard
Copied
Check that field is not empty before setting date:
var f = this.getField("NewLatestShippingDate").valueAsString;
var d = util.scand("dd/mm/yyyy", f);
if(f !== ""){
d.setDate(d.getDate()+14);
event.value = util.printd("dd/mm/yyyy", d);}
else
event.value = "";
Copy link to clipboard
Copied
Ok so idk what i did but ultimately got it to work! this was the code i used in case it can help anyone...
Thank you everyone who tried to help!!
var d = util.scand("dd/mm/yy", this.getField("NewLatestShippingDate").valueAsString);
var theTime = d.getTime () ; var oneDay = theTime + 14*24*3600*1000;
var dd = new Date(oneDay); event.value = util.printd("dd/mm/yy", dd)