CXone Studio ASSIGN action variable scope issue

Trying to set a variable in an ASSIGN block and check it in an IF block right after. The IF always goes to the else branch even though the ASSIGN should set the value.

Here is the snippet:

ASSIGN 
 output: 
 myVar: "test"

IF 
 input:
 myVar == "test"

The variable myVar is not persisting between the actions. Am I missing a configuration step?

The issue is that you’re defining output in the ASSIGN block, which means the variable lives in the output payload of that specific action. The IF block doesn’t automatically look at the output of the previous action unless you explicitly chain it or use a session variable.

You have two main ways to fix this. The cleanest is to use a session variable so it persists across the whole flow.

Option 1: Session Variable (Recommended)

Use session.myVar instead of just myVar. This puts the value in the session scope, which is accessible by any subsequent action in the flow.

ASSIGN
 output:
 session.myVar: "test"

IF
 input:
 - session.myVar == "test"

Option 2: Action Chaining

If you don’t want to use session variables, you need to reference the output of the previous action directly. In Studio, you usually reference the output of the previous step using the previous keyword or by explicitly wiring the output of the ASSIGN to the input of the IF.

IF
 input:
 - previous.output.myVar == "test"

I’ve run into this before when migrating from older flow logic. It’s easy to assume scope carries over implicitly, but Studio is pretty strict about where data lives. Check your action properties to make sure you aren’t accidentally creating a new local scope somewhere else. Also verify the IF condition syntax-it should be an array of conditions, not a single string.

If you’re still hitting issues, check the debug trace in the flow simulator. It shows the exact value of myVar at each step.