CXone Studio DBConnector returning empty result set

The DBConnector action in my Studio script keeps returning an empty result even though the SQL query works fine in SSMS. I’m using a parameterized query to look up customer records by ID. Here is the configuration:

{
 "action": "db_connector",
 "query": "SELECT * FROM Customers WHERE Id = @custId",
 "parameters": {
 "custId": "{{contact.custId}}"
 }
}

The connection string is verified. Why is the result set null?

You’re passing the parameter as a string literal inside the JSON config, but the DBConnector often expects the actual value to be resolved at runtime, not a template string. Also, SELECT * is risky if the schema changes. Try explicit columns.

Check if your contact.custId is actually an integer. If it’s a string in the contact data, you might need to cast it or ensure the DB column accepts it.

Try this structure:

{
 "action": "db_connector",
 "query": "SELECT Id, Name, Email FROM Customers WHERE Id = @custId",
 "parameters": {
 "custId": "{{contact.custId}}"
 },
 "connectionId": "your-connection-id"
}

If that still returns null, check the logs for the actual SQL being executed. Sometimes the parameter binding fails silently if the type doesn’t match. You might need to cast it in the query like WHERE Id = CAST(@custId AS INT).

Yeah, that’s exactly the issue. The DBConnector doesn’t evaluate the template string {{contact.custId}} if it’s nested inside the parameters object like that. You need to resolve the variable before the action runs. Use an Assign action first to map {{contact.custId}} to a flow variable, then pass that flow variable to the connector.

{
 "action": "assign",
 "variables": {
 "flowVars.lookupId": "{{contact.custId}}"
 }
}

Then in your DBConnector, reference the flow variable directly. It’s a pain, but it works.