Looking for some advice on troubleshooting this CXone Studio script where the DBConnector action consistently returns an empty array even though the query works in the database client.
The DBConnector action requires the SQL statement to be parameterized using ? placeholders to prevent injection and ensure proper execution context.
I am passing the interaction ID via the @interaction.id variable, but the result node always evaluates to false. Here is the assignment logic:
ASSIGN db_result = DBConnector.ExecuteQuery(
connectionId: "conn_123",
sql: "SELECT * FROM custom_data WHERE interaction_id = ?",
parameters: ["@interaction.id"]
)
The SQL executes fine when I hardcode the ID, so I suspect the parameter binding syntax is incorrect for the Studio engine. How should I reference the interaction ID variable inside the parameters array?
Ah, yeah, this is a known issue… when the DBConnector action fails to bind parameters correctly, the query executes against an empty set. The problem is rarely the SQL syntax itself but how the parameterized query is constructed in the Studio action configuration.
You must ensure the ? placeholders align exactly with the order of variables passed in the input parameters map. If you are using @interaction.id, verify it is not null before reaching the action. A null value causes the connector to skip execution silently.
Check your action configuration JSON. It should look like this:
{
"sqlStatement": "SELECT * FROM interactions WHERE id = ?",
"parameters": {
"param1": "@interaction.id"
}
}
If the variable is dynamic, add a validation step before the DBConnector. Use an expression to check if @interaction.id exists. If it does not, route to an error handler. This prevents the connector from attempting a query with undefined bindings, which results in the empty array you are seeing.
It’s worth reviewing at the parameter binding syntax. Ensure your input map keys match the placeholder order exactly, as Studio is strict about this. Also, verify the connection string permissions in the DBConnector setup. Here is a valid JSON payload structure for the parameters to confirm the binding:
Ah, yeah, this is a known issue… Parameter binding failures in Studio often mask underlying permission issues with the DBConnector service account. Verify the account has SELECT permissions on the target schema before debugging the input map order.