I have a payroll form that has a section for a submitted on date that is protected.
I need the form to default to the current date/time when the user opens it (and ultimately emails it to our Administrative folks) but when our Administrative folks open it up the date needs to still show the date the user submitted it.
I have tried several different methods in order to make this happen, to no avail.
Anyone have any solutions?!?!??! TIA
That is a pain isn't it. I have come across this before.
I add some logic to the form. The initial form when created must have a blank date time field
if(this.rawValue == null) //if the date time field is empty, get the current date
this.resolveNode("$").rawValue = util.printd("yyyy-mm-dd", new Date());
else //if it already contains a value, dont do anything.
What will happen then is that if the datetimefield already contains a date, the initialisation event wont do anything, but if it is blank upon opening the form. it will get the current date.
You can choose to display the time in a separate 'time' field or concatenate it into the same field as the date.
this.resolveNode("$").rawValue = util.printd("HH:MM:ss", new Date()); //in your dateTimeField, this will display the time with seconds and leading zeros. eg: 14:08:37
If you wish to have the date and time in the same DateTimeField:
//show the date and time separated with a space.
this.resolveNode("$").rawValue = util.printd("dd-mm-yyyy", new Date()) + " " + util.printd("HH:MM:ss", new Date());
This is displayed
Please mark as correct if satisfied. Thanks