We need to enhance our query function in the Salesforce integration by adding support for the throwOnEmpty feature. This feature should throw an exception or handle the case where the query returns zero results.
Current Behavior
Currently, when the query function in our Salesforce integration returns zero results, the job proceeds without any indication or exception. This leads to a tedious error handling job code
Eg:
const queryResult = state.references[0][0];
const accountExists = queryResult && queryResult.totalSize > 0;
if (!accountExists) {
console.log(`Account with External ID: ${state.account.External_ID__c} not found in Salesforce`);
}
Expected Behavior
When the throwOnEmpty parameter is set to true, the query function should:
Throw a specific exception when a query returns zero results.
Provide a clear error message indicating that no results were found.
Steps to Reproduce
Call the query function with parameters that will result in zero results.
Observe that no exception is thrown and the process continues as usual.
Proposed Solution
Add a throwOnEmpty parameter to the query function signature.
Implement logic to check the result size is bigger than 0.
If throwOnEmpty is true and the result set is 0, throw a specific exception with a descriptive error message.
Please feel free to reach out for any further details or clarification on this feature request. Thank you!
Description
We need to enhance our
query
function in the Salesforce integration by adding support for thethrowOnEmpty
feature. This feature should throw an exception or handle the case where the query returns zero results.Current Behavior
Currently, when the
query
function in our Salesforce integration returns zero results, the job proceeds without any indication or exception. This leads to a tedious error handling job code Eg:Expected Behavior
When the
throwOnEmpty
parameter is set to true, thequery
function should:Steps to Reproduce
query
function with parameters that will result in zero results.Proposed Solution
throwOnEmpty
parameter to thequery
function signature.throwOnEmpty
is true and the result set is 0, throw a specific exception with a descriptive error message.Please feel free to reach out for any further details or clarification on this feature request. Thank you!