0

A simple need but no success in default auto-numbering an integer type field in QField. Have tried $id, $row_number, etc., but no default value is entered on point digitization. An expression such as maximum("id") + 1 requires "apply default value on update" which appears to sometimes overwrite values on synchronization in QGIS - which is detrimental to 'permanently' indexing points in the data-collection/synchronization process. Have searched these posting and other on-line sources and tried all options found.

1 Answer 1

0

You said:

An expression such as maximum("id") + 1 requires "apply default value on update"

Although there is a caution that states:

"Using fields in a default value expression only works if 'Apply default value on update' is checked"

...this is NOT the case. I number sequentially across 3 layers (a point layer, a line layer and a polygon layer, with the following expression, and 'Apply default value on update' is NOT checked and it works.

Max(
    aggregate('tree_pt','max', "num"), 
    aggregate('tree_ln','max', num"), 
    aggregate('tree_ar','max', "num"),
    0)
+1

I use the Max() funtion with an argument = 0 to account for an empty dataset.

But, if you are using this sequence as a primary key in a multi-user environment, or will upload the data to a database elsewhere, you may wish to consider using a uuid; Set default = uuid().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.