Copy link to clipboard
Copied
Hi
I used this script to insert today's date.
this.getField("Today").value = util.printd("mm/dd/yyyy", new Date());
Will this keep a static date if the saved form is opened later?
If not, is there a scrip to use so it doesn't change later.
thanks
Leah
This script will only fill the "Today" field if it is empty, otherwise nothing will happen:
var oField = this.getField("Today");
if (oField != null && oField.value.length == 0) {oField.value = util.printd("mm/dd/yyyy", new Date());}
Copy link to clipboard
Copied
Where does you use the script?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Fill the field only when it is empty,
Copy link to clipboard
Copied
This script will only fill the "Today" field if it is empty, otherwise nothing will happen:
var oField = this.getField("Today");
if (oField != null && oField.value.length == 0) {oField.value = util.printd("mm/dd/yyyy", new Date());}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
It should works fine as a Document JavaScript
Copy link to clipboard
Copied
If the code is run it will update the field. It is up to you to make sure you only run it once, or modify it so it does nothing if the field is not blank.