The setting
In a QGIS model, I have an input layer polygon from which a grid is created.
On this grid-layer, a new attribute field should be created based on an expression that refers to the input layer polygon. That works well as long as I set a fixed name for the layer polygon - see the expression and the model linked here (at the bottom).
Basically, I just have to replace 'polygon' in the overlay_intersects-part of the expression in a way to refer to the model's input layer: overlay_intersects('polygon',$geometry) works, as long as the layer indeed is named 'polygon', but the model should be flexible to take the selected input layer here.
The question
How can the layer-name be defined so that it refers to the name of the input layer, regardless of its name?
What I tried
In the field-calculator dialog, I select pre-defined value and try to set my expression in 'single quotes' as described here in the style of: 'expression' || @loadpolygonlayer || 'expression'. For the layer to refer, I select it from the context variables as can be seen on the screenshot.
I also tried to get the name of the layer by using this syntax and different variations with and without quotes, with masking single quotes etc., with no success.


The issue here is that expression functions which operate on map layers (including get_feature_by_id ) don't currently have access to any temporary output layers created a step in a model. This applies to a lot of functions, including aggregates.– MrXsquared May 25 '21 at 16:34