[Blockly] How to reference a field_variable

In the process of developing a library to use my openhab-rules-tools library from Blockly I’ve encountered a problem I can’t solve from the tutorial nor the docs.

I have a block I’m trying to create that needs to create it’s own variable (kind of like a for loop has a variable). I can’t use a temporary variable (i.e. {{temp_name:desiredName[:realm]}}) for this because the users need to be able to reference the variable in a statements block.

I did discover field_variable which does exactly what I want (creates the variable, lets me rename it, variable shows up under “Variables”, the whole nine-yards.

However, I can’t figure out how to actually reference that variable in my code. Given.

          - type: field_variable
            name: VAR_NAME
            variable: item

in my code I’ve tried:

Attempt Output
{{field:VAR_NAME}} :Qdtlf+vg4rV7iO!.0yX or some other random string, clearly a unique identifier of sorts (maybe the id field (per Variable fields  |  Blockly  |  Google for Developers)). It doesn’t make sense to use the ID though because “item” gets added as a variable to the top of the code. I need the field’s text.
{{input:VAR_NAME}} a space, which is interesting as if the input value is undefined it’s usually “null”, isn’t it?
{{variable:VAR_NAME}} /* Invalid placeholder type variable! */
{{variables:VAR_NAME}} /* Invalid placeholder type variables! */
{{var:VAR_NAME}} /* Invalid placeholder type var! */
{{vars:VAR_NAME}} /* Invalid placeholder type vars! */

Have I run into a feature that OH doesn’t support perhaps?

only roughly tested
{{field:item}} ?

sadly I get null instead of the variable name.

Some more results from research.

Looking at the code and the JSON shown in the Advanced Blockly Playground (see below) the actual variable name which is what I need to access is stored in a separate Object in Blockly.

  "blocks": {
    "languageVersion": 0,
    "blocks": [
        "type": "controls_forEach",
        "id": "HJ5_3bM=emwf-c6noKH;",
        "x": 212,
        "y": 338,
        "fields": {
          "VAR": {
            "id": "1K,V(0,NN!f9h$3DZCzN"
  "variables": [
      "name": "j",
      "id": "1K,V(0,NN!f9h$3DZCzN"

This is going to require a new replacement field (e.g. {{fieldvar:VAR_NAME}}) and adding the VariableMap to the Block that’s passed into the code that processes these.

See [Blockly] Support blocks that create variables · Issue #2324 · openhab/openhab-webui · GitHub.