CXone Studio ASSIGN scope issue with IF blocks

I’m building a simple routing script in CXone Studio to check a customer’s account status. The logic seems straightforward: grab the status from an external API, check if it’s ‘active’, and set a disposition variable accordingly.

I’ve got a GetRESTProxy action that pulls the data. The JSON response looks fine in the debug logs. Then I have an IF action checking if $.response.status equals ‘active’. Inside the true branch, I’m using an ASSIGN action to set $.customVars.disposition to ‘Valid’.

Here’s the blem. When the condition is false, the variable isn’t just empty; it seems to retain the value from a previous iteration or default to something weird. I tried setting a default value in a separate ASSIGN block before the IF, but the scope seems off.

// GetRESTProxy Output
$.response.status = "inactive"

// IF Action
IF ($.response.status == "active")
 ASSIGN $.customVars.disposition = "Valid"
ELSE
 ASSIGN $.customVars.disposition = "Invalid"

The ELSE branch runs, but the downstream action sees null. I’m wondering if the ASSIGN inside the IF block creates a local scope that doesn’t persist to the global session context. Or maybe I’m missing a step to commit the variable?

I’ve checked the Studio docs, but they’re vague on variable scoping within conditional blocks. I’ve tried using the full path $.session.customVars.disposition but that throws a syntax error in the ASSIGN action.

Is there a specific way to ensure variables set in IF/ELSE blocks are available globally? Or should I be using a different pattern for this kind of branching? I’ve been stuck on this for two days. It feels like a basic setup, but the variable just won’t stick.

The ASSIGN action inside that IF block bably isn’t evaluating the path correctly. Studio paths are strict. Try using the full expression $.response.status in the value field, not just the raw JSON key. Also, make sure the IF condition uses the exact string ‘active’ with single quotes if it’s a literal comparison. Check the debug trace for the actual variable state before the assignment.