Skip to content
  • There are no suggestions because the search field is empty.

Quotes in Parameterized Instances 

This guide explains clearly why you need quotation marks in Parameterized Instances

What's Happening:

  • Instance attribute expressions are JavaScript. The Intelligence Hub uses GraalVM to execute the JavaScript in expressions
  • Parameters are substituted before the JavaScript runs. In instance expressions, {{this.param}} is replaced with the parameter's value, and then the resulting JavaScript is executed
    • To preview string results, use the Template view on the Input or Instance to see how the template resolves into a final string. Currently, there is no equivalent preview feature for Parameters.

Why Do Quotes Matter?

Because the value is pasted into your JS before execution, an unquoted string will be read as a bare identifier (or produce a syntax error). Quoting tells the JS engine it's a literal.

  • String values must be quoted wherever JSON is expected. HighByte's modeling docs call this our defaults (JSON form; "Strings must be quoted" ). The same rule applies when your instance expression produces JSON. 

When To Use Quotes:

  • You want a string path (IDs, paths, names):
"{{this.DeviceID}}"
  • You're building JSON / text expression (e.g., linking pieces of text)
"line-" + "{{this.lineID}}"

When Not To Quote:

  • Numeric / Boolean / Math: If the referenced value is used as a number or boolean, leave it unquoted so JS can evaluate it as a value:
{{Connection.OPC_Server.LineAPartsProduced}} + {{Connection.OPC_Server.LineBPartsProduced}}

Quick Examples of Instances: 

  • Setting string metadata values (note the quoted string)
{{Instance.myInstance}}["#name"] = "changeName"
{{Instance.myInstance}}["#model"] = "changeModel"
  • Building a JSON object that mixes a quoted string with another value
// Build a complex JSON value 

let value = {

"employees": {

"name": "steve",

"value": {{Connection.opc.tag}} //maybe reference a parameter instead of a component ref to align with title.

    }

};

return (value)
 

Takeaway

In Instances, is resolved first and then executed as JavaScript. If you mean text, wrap the reference in quotes so the JavaScript engine and any JSON you output treat it as a string.