Integrations that flow data to and from your Salesforce organization are awesome! But just like the organization itself, sometimes your integration hits a bump in the road in the form of integration errors. Today we’ll take a look at five Salesforce exceptions that break integrations and the most common causes so that you can take the necessary action to ensure your data flows smoothly.
Too many SOQL queries: 101
The System.LimitException: Too many SOQL queries: 101 error is perhaps the most common error on the Salesforce platform. An ExecutionLimit Exception occurs when more than the one hundred and first query executes during a transaction, such as updating a Contact record. The root cause of this error is frequently due to an Apex Trigger or Class that isn’t correctly bulkified.
You avoid this error by ensuring that Apex database queries (SOQL queries) happen outside of Apex looping operations. For example, when processing many contact records, you might begin by querying all parent accounts before processing each record instead of querying for accounts individually.
Attempt to de-reference a null object
The System.NullPointerException: Attempt to dereference a null object is also very common on the Salesforce platform and exclusive to Apex triggers and classes. This error happens when a variable unexpectedly does not have a value.
This issue is resolved by either updating the code for timely null checks, error handling or by improving the scoping of queries or other logic to ensure that variables always have values.
List has no rows for assignment to SObject
The System.QueryException is generally a plain error to understand: it simply means that an Apex (SOQL) query fails to find and assign a record to an SObject variable (e.g., Contact variable), but the query didn’t find the record, hence the error.
This issue can be avoided by having the query return a list of records and then looking in that list for the record returned.
The Field Custom Validation Exception error might just be the second most common on the Salesforce platform because it is tricky to avoid. This error generally happens when Apex code inserts or updates a record that violates a new or uncommon validation rule.
For example, you have a trigger that updates Account records perfectly. Later on, a new validation rule requires a picklist setting resulting in a Field Custom Validation Exception.
In these cases, the option is to update the validation rule to accommodate the Apex behavior or update the Apex code to comply with the validation rule.
The Inactive Owner or User error often happens when Apex code or system integrations attempt to insert or update records owned by an inactive user.
Fixing this issue typically requires improving the business logic or updating the source data to reference an active user in the system.
Organizations constantly add and improve their business processes and add new integrations every day. Salesforce integration error like these must get addressed promptly to ensure the quality of your data.
Are you looking for an outside perspective on your Salesforce errors or integration issues? Contact us for a free 30-minute consultation.