QField tracking: end time changes when I sync to cloud

I’m using QField to record GPS tracks and measure how long each track took (effort time). I have start_dt and end_dt fields.

I was able to automate most of the attributes, but I’m having a problem with end_dt:
the time that gets stored is often the time of sync to QFieldCloud, not the time when tracking actually stopped.

This seems to happen because of “Apply default value on update”:

  • I need to enable “Apply default value on update” so that end_dt captures the exact time when tracking is stopped.

  • But when the data is later synced or edited, the default is applied again and end_dt is updated to the sync time, which breaks my tracking duration.

What I would like to achieve

start_dt

  • Automatically set when tracking starts.

  • Never changed afterwards.

end_dt

  • Automatically set exactly when the user taps “Stop tracking”.

  • Never changed afterwards (not by edits, not by sync).

Duration

  • Calculated reliably from end_dt - start_dt.

  • No need for the user to tap or edit anything.

We work with Forest Guards who are not very familiar with technology, so we need this process to be as automatic and foolproof as possible, with no manual steps that can introduce human error.

Question:
Is there a way in QField to:

  • Tie end_dt to the “Stop tracking” event, and

  • Freeze that value so it is never changed again on sync or later edits?

If not, would it be possible to add such an option/feature?

Hi!

You can try only setting a new value when the field doesn’t already have one.
Assuming you are using now() to set your datetime, you can try something like this as your default value:
if ( is_empty_or_null( attribute(‘end_dt’) ), now(), attribute(‘end_dt’) )

This should only set a new date if the field is empty, otherwise set the existing date.

Hope this helps!

1 Like

Thanks a lot for the suggestion — that makes sense and looks like it would prevent end_dt from being overwritten on later edits/sync.

Just to confirm: with this expression, do I still need to have “Apply default value on update” enabled for end_dt so it gets written at the moment I tap Stop tracking? Or will QField apply the default automatically on that stop event even without the “on update” setting?

I’m trying to ensure end_dt is captured once at stop-time, then never changes afterward.