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.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked May 23, 2019 at 13:08

1 Answer 1

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.

answered Nov 21, 2019 at 18:20
1
  • 1
    just a remark: using 3.10 I had to use concat('\'', @text,'\'') Commented Nov 26, 2019 at 15:01

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.