2

QGIS 3.4.7

I have a lot of Models where there are some string inputs. In all of them, I have to enter the string between quotation marks ''. I understand the meaning and pourpose of them in any coding.

What I'm looking for is a way that the user doesn´t have to type the '' to avoid mistakes.

How could I concatenate '' with the string typed in the modeler?

That´s how a string input looks in the modeler.

enter image description here

The inputs given in the String Input are used in a simple Field Calculator to fill a new column.

1

In a model like this:

enter image description here

QGIS 3.4: In the field calculator you can call the Strng Input as a parameter by @NAME. The NAME will be the first name you give the input when you create it. Although this parameter is not explicit, it exists.

Concatenate single quotes before and after the value of this parameter at the Formula.

enter image description here

QGIS 3.6 or higher: From this version you can see the existing parameters. In the field calculator click on the E (expression symbol) in the formula and the parameters will be presented on this screen. The formula to be entered is exactly the same.

enter image description here

With this formula, any text entered in the input will be written as a string without the need for quotation marks by the user.

  • 1
    just a remark: using 3.10 I had to use concat('\'', @text,'\'') – César Arquero Nov 26 '19 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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