• @jkandasa,

    Is it possible to pass variables to a script? I have written a script and I would like to pass a delay time variable depending on what triggers it. Is this possible? I think it is be means of bindings but doesn't seem to work.

    I put { delaySeconds: 10 } as the script bindings on a Operation that executes the script, on the other end I do myImports.delaySeconds but the variable seems to be null.

    Can you provide an example of doing this if it is possible?


  • I think I figured it out...

    I thought the variables were passed as part of the myImports object, but they need to be imported using mcApi.variable().get("delaySeconds"); instead.

  • @imedia Script bindings are variables are completely different.

    Variables - You can update in single place and refer on multiple locations. If you want to change, change it on one place. We have to add it on Utilities >> Variables repository
    You can call this as you mentioned,

    myVar = mcApi.variable().get("my-variable");
    myVar.value; // Value 
    myVar.value2; // Value 2
    myVar.value3; // Value 3

    Script bindings- is unique for each script(from caller). You have to pass script bindings as JSON key, value. You can retrieve it as is, simply check delaySeconds, do not add anything in front like myImports.

  • I would use object oriented style since it's more structured and better for accessing instances with

Suggested Topics