<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<p>Hi,</p>
<p>I am trying to evaluate an expression on a selected feature in my Python code.</p>
<p>Here is my code:</p>
<p>-----------------</p>
<p>selFeature = selectedFeatures[0]<br />context = QgsExpressionContext()<br />scope = QgsExpressionContextScope()<br />scope.setFeature(selFeature)<br />context.appendScope(scope)<br />exp = QgsExpression('represent_value(routenr)')<br />routenNameNr = exp.evaluate(context)</p>
<p>------------------</p>
<p>The code above works fine for a "normal" expression, like e.g. "$length", but it fails for "represent_value(fieldname)". I guess this is because represent_value involves another layer (relation reference widget). How could I enhance my code so that "represent_value(fieldname)" would also work?</p>
<p>Thanks a lot for your hints!</p>
<p>Andreas</p>

</body></html>