DBConnector Studio Action: Handling null results in conditional logic

Hey everyone,

Running into a weird issue with the DBConnector action in . We’ve got a legacy SQL Server table that stores customer preferences. The script hits the DB, gets the record, and then needs to branch based on a specific flag.

Here’s the setup:

  • Action: DBConnector (Get Record)
  • SQL Query: SELECT pref_flag FROM customer_prefs WHERE cust_id = {{sys.customer.id}}
  • Success Condition: Record found
  • Failure Condition: No record found or SQL error

The problem isn’t the query. It works fine in the script debugger when a record exists. The issue is when the query returns zero rows. The DBConnector action seems to fail silently or return a null object that breaks the subsequent IF action.

I’ve tried wrapping the result in a null check:

IF {{db.result.pref_flag}} != null 
 THEN goto "Apply Preference"
ELSE 
 goto "Default Flow"

But the script still throws an error: Cannot read property 'pref_flag' of null.

I’ve also tried checking the {{db.result}} object directly for existence, but doesn’t seem to have a clean “Is Null” operator for object properties in the visual builder.

Has anyone found a reliable way to handle empty result sets from DBConnector without the script crashing? I don’t want to add a “WHERE 1=0” fallback query just to handle this.

Current environment:

  • CXone Org ID: [REDACTED]
  • Version: Latest (as of Oct 2023)
  • DB Type: SQL Server 2019
  • Connector Mode: Direct SQL

Any help would be appreciated.