Skip to main content
edited tags
Link
Source Link

Create field with sequential automatic alphanumeric name in QField

I've created a series of layers in QGIS to collect data in field with mobile app QField. Each layer have a rule to make its names.

For example, one layer is modeled to collect corn fields. It has several attributes and its name field should be filled with value C1 for the first point, C2 for the next one and so on. I need to set the layer form with autofill sequentially. If I registered four corn points, I'll have C1, C2, C3, and C4. Once the user in field mark another corn points, the app show the form with the fifth point autofilled with C5, unique, not null and read-only. Later, the user has to delete C2 and the latest points (C3, C4 and C5) got automatically updated to minus one unit (C2, C3, C4).

I've tried to create the name field as a virtual field and use the expression 'C' + @row_number but apparently, @row_number only works with regular fields. In the Attributes Form I got no options for that, not even a PyQGis approach in the internet.

Any ideas?