Skip to content

Error when adding child feature and different ID value in Qfield and QGIS #2359

@Tars4815

Description

@Tars4815

Hello everyone,

I'm currently working on a Qfield project in offline editing dealing with different PostGIS layers to be updated on field. The last test resulted in a series of problem connected to the element ID value stored and visibile in Qfield and the corresponding one in the syncronized QGIS project. Also, a layer that is part of a 1:n relationship does not allow to add a child element in its form in Qfield environment showing the following error message: "Cannot add child feature: parent primary keys are not available". I don't know if this two issue are connected.

Reproduction Steps:

  1. Preparation of the project in QGIS 3.16 for the export in Qfield 1.10 in editing offline. The project contains PostGIS point layers and one of them has a 1:n relation with another table.
  2. Export for Qfield using the Qfield Sync plugin
  3. Opening the project in Qfield and adding a new point to the parent layer
  4. Adding with the add-button the child element inside the parent form

Expected behavior:

Qfield opens the child form for editing all the needed attributes for the child element before saving.

Observed behavior:

The error "Cannot add child feature: parent primary keys are not available" appears on screen and the child form doesn't open.
Also, ID is always equal to 0 for each new parent element while, after importing the project back in QGIS, a different number ID is stored in the Attribute Table.

This happens only with newly created element in the parent layer. It does not happen with element already existing in the parent layer in the project for which it is easily possible to add child features as expected.

Screenshots and GIFs

ID visible in Qfield

ID stored in Attribute Table after importing in QGIS

Error message in Qfield

QField version: [Qfield 1.10 (1da006)]

Additional information:

  • Problem started happening recently, didn't happen in an older version of QField: [Yes]
  • Problem can be reliably reproduced, doesn't happen randomly: [Yes]
  • Problem happens with all files and projects, not only some files or projects: [Yes]

Thanks in advance for your kind support and help in understanding and solving this issue,

Federica

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions