Dollar sign expansion using expression - differences between script and object formulas
Perhaps this is common knowledge (still not documented anywhere, though, and I'd say the official documentation is downright confusing regarding this), but dollar sign expansions of this type:
work in object formulas, but don't work in the load script. In script, they always evaluate to null/empty string.
There is one exception though - if the expression is a single number literal, it will work. So this:
will still evaluate to the number 123, no matter if used in script or in the frontend.
This can be occasionally useful if you have defined a variable which takes other variables' names as parameters, which are then called with $($1) syntax. If you replace one of the parameters with e.g. =123, you can pass a numeric constant as a parameter instead of having to use a variable.