Add timestamp when form complete
Copy link to clipboard
Copied
Following on from other questions regarding a form I am creating, I would like to show the time that the form (a checklist) is completed.
The checklist has multiple sections.
A textbox for each section shows % complete for that section (i.e. % of checkboxes checked).
One textbox for the whole form shows % of sections complete (i.e. % of section textboxes which equal 100%).
All these % complete boxes will be coloured green when they reach 100%
Once the whole form is 100% complete, the textbox txtTimeCompleted should be populated with the data & time of completion.
So to the question. How do I show the time that the form has been completed? The method should be as easy as possible to understand with a minimum of coding.
I tried Text Field Properties / Calculate...Value is the Maximum of txtDoerTime1, txtDoerTime2 (each of these textboxes are populated with times e.g. 29/Sep/17 10:24 am). At first this resulted in NaN (which I guess is Not a Number). So I changed the format, but now there is no value returned. Any suggestions here?
Perhaps I should be using a Custom Calculation JavaScript. I was thinking it would work using the textbox txtTimeCompleted. i.e. return the time when the value in that box is 100%.
Any suggestions appreciated:)
Copy link to clipboard
Copied
If you are going to use a script to fill-in the date and time the form has been completed, I would set the "Format" to none and use the util.printd() method to format the result displayed in the form.
How do you want this action to be triggered?
You can have a validation script for each section that verifies all the sections are 100% complete and then runs a script to fill-in the field.
You could add a button that needs to be clicked to fill in the field and part of that script will be to check that all the sections are 100% complete.
You also need to consider what will happen if the user goes back and removes check mark from one or more sections and the form is not longer complete.
Using a button to complete the field "txtTimeCompleted" would have a script like:
this.getField("txtTimeCompleted").value = util.printd("dd/mmm/yyyy hh:MM tt", new Date());
Copy link to clipboard
Copied
am trying to create this form in my spare time, and not finding much spare, and am not a coder...so thanks for your help, and apologies for tardy replies. Much appreciated.
To paraphrase,
Option 1 - when value in a text box txtChecklistDoer% = 100%, then txtTimeCompleted is automatically populated with the date and time. So the trigger is that this calculation = 100%, and that is dependent on the different sections being complete.
Option 2 - when user clicks on a button "Complete", then txtTimeCompleted is populated with the date and time
I prefer option 1 as why get the user to press a button when the act of ticking the final check box indicates that the checklist is complete.
But yes I am coming up with the difficulty of how to deal with the scenario where a box in unchecked. As an example, I have a % complete field that uses Simplified Field Notation to calculate "txtCount1Doer / txtCount1". So it should give me a 100% figure for instance when the number of boxes that are checked (txtCount1Doer) equals the number of boxes there are (txtCount1). This works well at first but not when I try and break it. It doesn't automatically update when a box is checked/unchecked...so although the two count fields are correct, the % complete might show for instance 50% complete when only 1 out of 4 boxes are checked. Is there a way perhaps to force the % complete text field to be updated when the count of checked boxes changes? If I have to use a script then what suggestions do you have?
I'm kind of digressing but I think this problem needs to be resolved too, in order for option 1 to work.
For option 1, can you assist with the scripts?
In quasi code...
A. % Section Complete
% SectionComplete = count of checked boxes / count of boxes
B. % Checklist Complete
If for all sections % SectionComplete = 100%
Then % Checklist Complete = 100%
And this field should be highlighted in green
C. Time completed
If % Checklist Complete = 100%
Then Time Completed = current date time
Hope that makes sense

