Common Salesforce Errors and Solutions

Common Salesforce Errors and Solutions

Salesforce is a top customer relationship management (CRM) platform with many features to improve business processes and boost productivity. However, users often run into common Salesforce errors and solutions while using it. This blog will highlight some of these frequent issues and provide practical solutions to help you fix them quickly.

By understanding these common errors, you can ensure a smoother experience and get the most out of your Salesforce org.

Salesforce users frequently encounter a range of issues that can disrupt their workflows. Below are some of the most common Salesforce errors and practical solutions to address them.

Login Issues 

Sometimes a user might face some difficulties in logging into their account. There can be multiple reasons a user faces this issue, such as Attempting wrong passwords, Outside of IP Ranges, or Outside of Login hours.

As an admin, we can check that particular user’s password policies and login history. To navigate to Login history, Go to Setup –> User –> Click on that User –> Login Histories

Login History

 

For Passoword policies,  Navigate to setup –> Search of Passoword Policies. Here we can check the invalid login attempts, and lockout period.

 

Password policies

 

System.LimitException: Too many DML statements: 151

This is a type of Exception we encountered when there is DML inside the loop and that loop is running more than 150 times as the Total DML statement allowed per transaction is 150.

DML Limit error
Sample Code

System.LimitException: Too many SOQL queries: 101 

We generally encounter this error when we do a query inside the loop and that transaction runs more than 100 times, then we get Too many SOQL 101 issues. Below is the error and the demonstration.

Query 101

Sample Code

An Internal Server has occurred

This type of issue we generally face is due to connectivity or cache. So try to refresh the page, check your internet connection, clear your cache, or log in again with a different browser.

Invalid field ‘X’ on sObject ‘Y’

We might get this issue if we access the wrong field that is not present on that object or if the user doesn’t have permission.

FIELD_CUSTOM_VALIDATION_EXCEPTION

When we have some validation actively running on the sObject and matching the validation criteria while saving the record, we encounter this error. For example, we are inserting an account here without providing the value in the Account Number on which we have the validation error that the field can’t be empty. We faced this type of error.

 

Custom validation

 

Attempt to de-reference a null object

When we have some object or attributes referenced by X that are null or not initialized before accessing it, we will see this error. So, check if it is properly initialized or has the value. Here we are simply adding two integers but not initialising the ‘x’.

We sometimes also get this error when we query some records insert them into a list and then access that list, If that query is not returning any records then the list will contain null. So properly apply a null check in your code before applying any logic to avoid such an exception.

Sample Code

null error

 

The apex heap size is too large

In Salesforce we have a 6 MB heap size for synchronous and 12 MB for asynchronous. We encounter this error when too much data is being stored in memory during processing. We have to review our code and follow the best practices.

Apex CPU time limit exceeded

In Salesforce CPU Time is calculated based on all the executions on the Salesforce application servers occurring in one Apex transaction—for the executing Apex code, and any processes that are called from this code, such as package code and workflows. Time spent in DML, SOQL, and SOSL isn’t counted.

To avoid such errors we need to follow Apex’s Best practices like filtering out your query so that processing will be on the limited data. avoid DML inside loops, avoid query inside loops, and try to use aggregate SOQL if needed.

Too many Query rows: 

As we know, the Total number of records retrieved by SOQL queries is 50,000. So when the SOQL has more records we will have this error. Try to use the Batch process here as it has a higher number of limits and we should filter out the data to get the necessary data only.

System.ListException: List index out of bounds: 0

If our query is returning 0 records and if we trying to access the element at row 0 then we will face this error. Apply proper null check, if the list is greater than 0 before accessing the element.

Sobject row was retrieved via SOQL without querying the requested field:

If we try to access some field without providing it in the SOQL then we will get this error.

Sample code

 

SOQL

Want to Learn Salesforce Flows? Checkout our Salesforce Flow Course

FAQs

Q1. How do we avoid SOQL 101 error in Salesforce?

We can avoid SOQL 101 error by avoiding DML statements in the For loop and bulkify the triggers.

Q2. What is the REQUEST_LIMIT_EXCEEDED error in Salesforce?

If you are receiving this error, it indicates that you have exceeded your Salesforce API request limit. This typically happens when a high volume of Salesforce API calls is made within a 24-hour period.

Q3. How do you handle the CPU time limit exceeded in Salesforce?

Following are the tips to handle the CPU time exceeded in Salesforce:
  • Write a single trigger per object.
  • Use one flow per object and event.
  • Avoid using Process Builder.
  • Prevent recursion in Apex code.
  • Avoid nested for loops.

Conclusion

In conclusion, while Salesforce is a potent tool for managing customer relationships and business operations, it is not without its challenges. You can significantly reduce downtime by familiarizing yourself with the common Salesforce errors and their solutions. Maintained the seamless functionality of your CRM system.

Remember, the key to overcoming these issues lies in staying informed, proactive troubleshooting, and leveraging the wealth of resources available within the Salesforce community.

With these strategies, you can ensure that your Salesforce environment continues to operate at peak performance, driving your business success forward.

Get a complete Roadmap To Learn Salesforce Admin And Development

Share Now

Kashish have extensive Salesforce development experience, holding 4 Salesforce certifications. she posses expertise in Apex, Lightning Web Components, and Salesforce Admin, with a track record of successful project delivery. As a dedicated Salesforce enthusiast, she actively seek and embrace new challenges and opportunities within the dynamic Salesforce ecosystem.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *