Using the new @alg decorator structure I am trying to populate a drop down with the fields (attributes in a table).

Using the code in https://docs.qgis.org/3.22/en/docs/user_manual/processing/scripts.html#the-alg-decorator

I have

@alg(name='searchupdatealg', label='Search and update (alg)',
     group='mgm', group_label='Example scripts')
# 'INPUT' is the recommended name for the main input parameter
@alg.input(type=alg.SOURCE, name='INPUT', label='Input vector layer')
@alg.input(type=alg.FIELD, name='Attrib', label='Attribute')
# 'OUTPUT' is the recommended name for the main output parameter

Looking at older code as in http://www.qgistutorials.com/fi_FI/_images/8b.png

It looks like we have to get the fields and put them into the list -but how is this done when we have @alg.input(type=alg.FIELD ...

1 Answer 1


No need to put the fields into the parameter's combobox manually. Just add parentLayerParameterName='INPUT' to @alg decorator.

@alg.input(type=alg.SOURCE, name='INPUT', label='Input vector layer')
@alg.input(type=alg.FIELD, name='Attrib', label='Attribute',

There is no explanation about this in QGIS Processing Script Documentation. But the parameter name comes from the constructor method of QgsProcessingParameterField.

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.