CXone Studio: Nested IF logic failing with ASSIGN action

Trying to understand why my nested IF block ignores the ASSIGN result. I am mapping CRM data to a variable, then checking its value. The logic seems correct, but the flow always exits the IF block.

  1. ASSIGN {{Contact.Phone}} to {{Temp.Phone}}
  2. IF {{Temp.Phone}} is not null
  3. ASSIGN {{Temp.Status}} to “Verified”
  4. ELSE ASSIGN {{Temp.Status}} to “Unverified”

The ELSE branch always executes. Is there a scope issue with these actions?

Check your variable scope and data type casting within the Studio block. The issue you are describing is a classic symptom of how CXone handles asynchronous data retrieval versus synchronous block execution. When you pull {{Contact.Phone}} from the CRM integration, it is often a string or an object, not a primitive value. If the CRM payload returns an empty string "" instead of a true null, the standard “is not null” check might pass, but subsequent logic fails if it expects a specific format. Conversely, if the data hasn’t fully populated by the time the IF block evaluates, it treats the variable as undefined.

To fix this, you need to ensure the data is explicitly cast and checked for emptiness, not just nullity. Instead of a simple nested IF, use a single IF block with a compound condition. Here is the corrected configuration:

{
 "type": "if",
 "condition": {
 "operator": "AND",
 "conditions": [
 {
 "attribute": "{{Contact.Phone}}",
 "operator": "NOT_EMPTY",
 "value": ""
 },
 {
 "attribute": "{{Contact.Phone}}",
 "operator": "IS_NOT_NULL",
 "value": null
 }
 ]
 },
 "then": [
 {
 "type": "assign",
 "variable": "{{Temp.Phone}}",
 "value": "{{Contact.Phone}}"
 },
 {
 "type": "assign",
 "variable": "{{Temp.Status}}",
 "value": "Verified"
 }
 ],
 "else": [
 {
 "type": "assign",
 "variable": "{{Temp.Phone}}",
 "value": ""
 },
 {
 "type": "assign",
 "variable": "{{Temp.Status}}",
 "value": "Unverified"
 }
 ]
}

The key is using NOT_EMPTY alongside IS_NOT_NULL. This prevents the flow from proceeding if the phone number is an empty string, which often happens with dirty CRM data. Also, ensure that the CRM lookup action has a “Wait for completion” flag enabled. If the CRM call is asynchronous, the IF block executes before the data arrives, resulting in the ELSE branch always triggering. Verify the action settings in the Studio UI to ensure synchronous execution for this specific lookup.