Nested Scripts?

Is it possible to nest a script in another script call? For example…

{CALL:new.parseEntityData({CALL:new.processID()},‘ID_NAME’)}

… or is there another way to achieve the same result? I’m still fiarly new to the scripting world. I could be going about this all wrong…

Thank you!

Yes, i think you can nest {CALL:X} functions, but sometimes it gets a bit tricky and might not work exactly as expected.

Break it Down into Steps

Instead of trying to put one {CALL:X} inside another, try separating them. For example:

  • First, call {CALL:new.processID()} by itself and store the result in a variable.
  • Then, use that variable when you call {CALL:new.parseEntityData(variable,'ID_NAME')}.

Make a New Script that Combines Both Calls, create a separate script function to do both steps

function getParsedEntityData() {
    let processID = new.processID(); // Step 1: Get process ID
    return new.parseEntityData(processID, 'ID_NAME'); // Step 2: Use it in the next function
}

instead of nesting {CALL}s, just call {CALL:getParsedEntityData()} directly in your rule or automation. This way, the script does all the work for you!

1 Like

That is exactly what i needed! Thank you! I ended up using an Update Program Setting rule that called my script, passing the variable to be parsed from the ID. Thus returning the json data I needed. (I think I’m explaining that correctly.) haha

The forum to the rescue again! You guys are amazing!