Is it possible to use a boolean as an input and if it is true then the field will be created?enter image description here

enter image description here


Yes, use the following expression to connect the boolean input to the tool:

If(@blnCreateField, 'FieldName', '')

For clarity, @blnCreateField returns either True or False depending if the checkbox for the parameter was checked or not. So the if statement checks if the first condition is true and, if it is, then return 'FieldName' else return nothing.

  • the model does the job well, but when I export it to python then I get an error like "Unable to execute algorithm Field name is not set. Please enter a field name". I think it is a bug. – kjp Jan 16 at 8:59
  • @kjp - You should probably ask this as a follow-up question to this one and include the code of the exported python script. It may be that the code will need to be edited to run it as a script. – Joseph Jan 16 at 10:39

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.