3

In the Value map widget can we select one value to be the default?

I don't want to apply on update as users may choose a different value. I just want the default to be 'u' so in edit mode, I can click on the drop down and then go to the next polygon and have it apply 'u'. Just saves a few seconds.

enter image description here

and

enter image description here

1 Answer 1

6

Assuming your file has at least one other field (e.g. "notes"), you could use the following expression as your default value and enable 'Apply default value on update' without it overriding other value selections.

if("notes" is not null,
   coalesce("values",'u'),
   coalesce("values",'u'))

The reference to another field is required in order for the GUI to show the default value in the dropdown box at form open.

However, the visual (even with an enforced non-null constraint) is misleading, as even if it looks like u (default value) has been selected, no value will be saved until you make some kind of update to the feature as demonstrated below.

enter image description here

So you have two options:

(a) Require the user to update the form with a 'check' field and make that field have an enforced non-null constraint (unfortunately, in QGIS 3.34.3 this seems to not work for checkbox widgets, which are the only one-click update widget), to force an update and save the default value, or

(b) Assign the default value into the field using Field Calculator and rely on users (or other custom constraints) to visually check that this is the appropriate value before moving on

2
  • Thanks. This will be useful but for this use case there are no other fields that are changed except when we have a 'y' to record. I found that I can just press 'u' to get that value from the drop down list and keep my mouse on the fwd button in the QGIS form to go to the next record, so that works well without having to move the mouse. BTW how did you create the animation in your answer?
    – GeorgeC
    Commented Feb 20 at 9:24
  • 1
    If nothing else is being updated then either your method or (b) in the answer sounds like the way to go. I used ScreenToGif to create the screen recording.
    – she_weeds
    Commented Feb 20 at 10:02

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.