opengisch / QField

A simplified touch optimized interface for QGIS

Home Page:http://www.qfield.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible regression of QField when using Boolean type fields

Meykaefer opened this issue · comments

During recent fieldwork, colleagues encountered an issue with our QField project. Our project has a list of staff members, and each member is assigned a status indicating whether they are already active during the season. This status was used to filter the results in the value relationship widget, and only active staff (i.e., 'true') were shown in the combo box for selection, while inactive staff ('false') were hidden. This worked very well last year at the end of the season, but after returning to the field, we don't get any results in the box that usually lists staff. I replaced the boolean type field with an integer and assigned two values: 1 for true and 2 for false. After changing it to an integer value, the combo box shows the staff as it was by the end of last season.

Expected behavior

Expected behaviour is that QField would utilise the boolean type field values.

Observed behavior

The boolean type fields work in QGis but not in Qfield. Replacing boolean-type field values with integer values allows it to work in QField

Desktop (please complete the following information)

  • OS: [Windows 11]
  • QGIS Version [3.34.3]
  • QFieldSync Version N/A

Mobile (please complete the following information)

  • Device: [IPad 9th gen]
  • OS: [OS 17.2]
  • QField version: 3.2.2 (72be17 v3.2.2)]

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

Can you provide a minimal project with as little attributes and layers as possible to reproduce this behavior?

For the record I suspect it's this upstream regression that got fixed not too long ago:

qgis/QGIS#57060

@m-kuhn I made a sample project and attached it here.

The sample project contains an Employee layer with two columns for their active status. One column is a boolean type, and the other is an integer. When you select the fieldnotes layer and create an entry, go to the Crew tab, and select a region in the Team dropdown, the boolean box will remain empty, while the integer box will display values.

Also, this only happens in QField but not in QGis itself.

I hope this helps!

Sample Project.zip

@m-kuhn I made a sample project and attached it here.

The sample project contains an Employee layer with two columns for their active status. One column is a boolean type, and the other is an integer. When you select the fieldnotes layer and create an entry, go to the Crew tab, and select a region in the Team dropdown, the boolean box will remain empty, while the integer box will display values.

Also, this only happens in QField but not in QGis itself.

I hope this helps!

Sample Project.zip

In QField v3.2.2 and QGIS v3.36.2, I was unable to reproduce the issue you are experiencing.

Test Qfield checkbox boolean field 002.pdf

Hi @SeqLaz

I just looked at the pdf you uploaded maybe I wrote the instructions a little confusing. You used the employees layer but the crew selection actually happens in the "fieldnotes layer". (People usually don't see the Region and Employees layer - both layers are usually invisible)

See the three screenshots below

  1. select Fieldnotes layer and start editing
    IMG_0098

  2. Go to crew tab and select a region. The box on top uses the boolean field and the one at the bottom an integer
    IMG_0099
    IMG_0100

the boolean field combo box remains empty. If you go to the properties of the layer and look at the widget setup both boxes are identical with the only difference that the top one utilizes a boolean type field while the one at the bottom uses an integer

Hi @SeqLaz

I just looked at the pdf you uploaded maybe I wrote the instructions a little confusing. You used the employees layer but the crew selection actually happens in the "fieldnotes layer". (People usually don't see the Region and Employees layer - both layers are usually invisible)

See the three screenshots below

  1. select Fieldnotes layer and start editing
    IMG_0098
  2. Go to crew tab and select a region. The box on top uses the boolean field and the one at the bottom an integer
    IMG_0099
    IMG_0100

the boolean field combo box remains empty. If you go to the properties of the layer and look at the widget setup both boxes are identical with the only difference that the top one utilizes a boolean type field while the one at the bottom uses an integer

Hello @Meykaefer,

I understand now, the issue is not with QField. The problem lies in the expression you are using. You have used the string 'true' instead of a boolean type. For a boolean, you need to follow the SQL language convention and use True or TRUE, without any quotation. You will notice that in the expression editor, the boolean type is highlighted with a different color than strings. To fix the issue, you just need to change the string to a boolean type.

Test Qfield checkbox boolean field 003.pdf

Hi @SeqLaz,

Thank you for figuring this out! Nonetheless, I do think something changed somewhere along the line. I have field projects that from December which are set up identical to the sample I provided and I was able to record the crew on site. And once we returned from the winter break it all of a sudden didn't work anymore.

That is the reason I thought it could be a possible regression since something that previously worked stopped working.

Thank you for pointing out the reason and providing a solution!

@Meykaefer , can you try the sample project that stopped working against the APK here: #5216 (comment) ? Thanks

@nirvn , I would gladly test the APK, but I don't know how to do it. I only have access to iOS devices, and I don't know how to install this APK. If you have some instructions on what I need to do I can do and test it.

Hey @nirvn It is not possible to use a string 'true' as a replacement for a True type value when using the compiled version of QField and the original project shared by @Meykaefer.

Test QField compiled preview checkbox 001.pdf