<div dir="ltr"><div>Hi,</div><div><br></div><div>I would like to propose a QgsProcessingParameterEnum automatically filled with data from a layer, exactly in the same way QGIS does with the form value relation widget.</div><div>Basically, the alg author would choose the layer, the key field, the value field, to order or not by value, and an optionnal filter.<br></div><div></div><div><br></div><div>I would like to know if someone had already done it, and if so, I there is some example code online.</div><div><br></div><div>If not, I think I would do this:</div><div><br></div><div>* create a new QgsProcessingParameterValueRelationEnum inherited from QgsProcessingParameterEnum</div><div>* use the input metadata to gather the parameters of the datasource. For example for PostgreSQL, I would add the connection parameters (service) and the schema and table name. An filter option would be great too.</div><div>* add methods (or override existing one ?) to gather the data and then use the setConditions methods to fill in the combobox.</div><div>* I should also add a new method parameterAsValueRelationEnum to get the code based on the selected item</div><div><br></div><div>I could also just call the setOptions method inside the alg, but it would be harder to maintain accross algs, and it does not seem to be the right "processing" way of doing it.<br></div><div><br></div><div>Or I could also use the setMetadata method with a widget_wrapper, such as done for the ConnectionWidgetWrapper ?<br></div><div>        db_param.setMetadata({<br>            'widget_wrapper': {<br>                'class': 'processing.gui.wrappers_postgis.ConnectionWidgetWrapper'<br>            }<br>        })</div><div>and then do the magic inside a dedicated class ? How ?<br></div><div><br></div><div>Any help appreciated.</div><div><br></div><div>Regards,</div><div>Michaël<br></div></div>