Start - Stop time function based on now()

764
3
Jump to solution
06-20-2018 05:50 AM
ThomasPerriment1
New Contributor III

Hi everyone,

I've been looking into the use of a "Stop" time button (End Standing Time) within a repeat, upon which a related dateTime (Finish Time) would appear with the current time appearing when the stop button (as a likert) is selected. 

My issue is that if I set the default time for the Finish Time to now(), it will give me the time at the first opening of the repeat and not the current time, and if I set the calculate field as now() whilst it does give me the correct time, it will refresh the time whenever I cycle through the repeats (going from 2 of 2, back to 1 of 2).

I am hoping to have a stop button which will set the Finish Time as current time when selected, with this time not automatically recalculating and changing when I go back (current workflow shown below). The XLS form is as follows: 

Step 1: Create first repeat entry.

Step 2: Select Stop button auto-calculating Finish Time to now()

Step 3: Create second repeat entry.

Step 4: Click back to first entry to find Finish Time has updated from 13:45 to 13:46.

Is anyone able to suggest a workaround for this?

Thanks and regards,

Thomas

0 Kudos
1 Solution

Accepted Solutions
DeonLengton
Esri Contributor

Hi Thomas

I havent attempted this yet but one thing caught my eye:

if I set the calculate field as now() whilst it does give me the correct time, it will refresh the time whenever I cycle through the repeats

To stop this from happening you can use the once() function which will force the calculation to only happen once and not each time the user scrolls through the repeat items.

Regards

Deon

View solution in original post

3 Replies
DeonLengton
Esri Contributor

Hi Thomas

I havent attempted this yet but one thing caught my eye:

if I set the calculate field as now() whilst it does give me the correct time, it will refresh the time whenever I cycle through the repeats

To stop this from happening you can use the once() function which will force the calculation to only happen once and not each time the user scrolls through the repeat items.

Regards

Deon

ThomasPerriment1
New Contributor III

Hi Deon,

Thanks for the quick response! This worked perfectly and was exactly what I was looking for. Thanks for your help.

Kind regards,

Thomas

HillarySherrill
New Contributor II

Hi Thomas -

I wanted to follow up with your post about how you approached the Start - Stop time function in Survey123 repeats. Using your example and the advice from the responder, I'm trying to get it to work with the once() but I can't seem to get it right and I'm wonder if I', missing something else on that line of the xls form.  Below is your screenshot from your original post.  When you got it to work, did you just replace now(), with once()?  Are there any other columns that require something other than what you showed?  When I put that formula in the calculation column and try to save I get an error.

HillarySherrill_0-1631713145523.png

Once the user selected the stop button, did that then make the finish time box come up (relevant) and then populate the date and time? 

Thank you!

Hillary

 

0 Kudos