Studio ASSIGN action overwriting IF logic evaluation

Just noticed my Studio script is skipping the ELSE branch even when the condition is false. I have an IF action checking if a variable is empty, but the ASSIGN action right before it seems to reset the state. Here is the snippet. Is the order wrong?

IF ({{customer.status}} == "active")
 ASSIGN {{result}} = "valid"
ELSE
 ASSIGN {{result}} = "invalid"

The ELSE block never fires.

Try using a Set Variable action to force re-evaluation of the customer.status variable. CXone variables can sometimes hold old values if not refreshed before the IF condition.

SET VARIABLE {{customer.status}}
IF ({{customer.status}} == "active")
 ASSIGN {{result}} = "valid"
ELSE
 ASSIGN {{result}} = "invalid"

The ELSE block should then execute as expected.

1 Like