Is it possible to use an optional variable (value2) like

@qgsfunction(args='auto', group='Custom')
def my_test(value1, value2=True, feature, parent)

in a custom function? Using QGIS 3.8

...likeenter image description here


Not sure of a direct way but there is the handlesnull flag which when set to true would let you input NULL as a parameter value.

@qgsfunction(args='auto', group='Custom', handlesnull=True)
def my_test(value1, value2, feature, parent):

You might want to include some logic in your code to determine what happens when a parameter value is NULL.

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.