5-Mistakes-to-avoid-in-Salesforce-Development.jpg5-Mistakes-to-avoid-in-Salesforce-Development.jpg
Salesforce Development

Salesforce Development: 5 Common Mistakes and How to Fix Them

Here are 5 common mistakes people make during salesforce development, so you can avoid them.
5-Mistakes-to-avoid-in-Salesforce-Development.jpg5-Mistakes-to-avoid-in-Salesforce-Development.jpg
Salesforce Development
Salesforce Development: 5 Common Mistakes and How to Fix Them
Here are 5 common mistakes people make during salesforce development, so you can avoid them.
Table of contents
Table of contents
1. Reaching SOQL queries limit
2. Multiple Triggers on the same object
3. Not Bulkifying your code
4. Troublesome User Experience
5. Keeping Hardcoded programs
FAQs

Salesforce development and customization requires a sound knowledge of Force.com. Visualforce is a framework that allows developers to build sophisticated, custom user interfaces that can be hosted natively on the Force.com platform. Apex is the native programming language of Force.com that lets you execute flow and transaction control statements. But unlike usual coding platform, Salesforce imposes limits due to its multi-tenant cloud structure. Below are 5 mistakes a Salesforce Development team should avoid while customizing on Force.com

1. Reaching SOQL queries limit

As a multi-tenant vendor, you can’t allow a customer on a CRM instance make millions of API calls per a minute. Because this can affect the performance for other customers on the same instance. Thus, Salesforce has kept governor limits which restrict the no. of API calls over a period, which prevents writing bad code and eating up of cloud processing space. One such governor limit is imposed on Salesforce Object Query Language (SOQL). The total number of SOQL queries issued are 100 in synchronous limit and 200 in the asynchronous limit. It is advisable to follow proper guidelines while using Apex code, such as avoiding queries inside FOR loops, using Apex collections, writing exhaustive test cases etc.

2. Multiple Triggers on the same object

Apex triggers enable you to perform custom actions before or after events to records in Salesforce, such as insertions, updates, or deletions. But for a particular scenario (such as ‘before insert’) it is advisable to write single trigger. Writing multiple triggers renders the system unable to recognize the order of execution. Moreover, each trigger that is invoked does not get its own governor limits. Instead, all code that is processed, including the additional triggers, share those available resources.

3. Not Bulkifying your code

Bulkifying your code refers to combining repetitive tasks in Salesforce Apex such that the code properly handles more than one record at a time. Neglecting bulk code leads to hitting governor limits. When a batch of records initiates Apex, a single instance of that Apex code is executed, but it needs to handle all of the records in that given batch. For example, a trigger could be invoked by a Force.com SOAP API call that inserted a batch of records. So if a batch of records invokes the same Apex code, all of those records need to be processed as a bulk, in order to write scalable code and avoid hitting governor limits.

4. Troublesome User Experience

Visualforce allows you to develop a rich UI with pop-ups and images, but can be troublesome for the user. Pages overloaded with data and functionality makes clicking or navigating to buttons difficult. Design in Visualforce should be around specific tasks with defined workflow and navigation between tasks. Also unbound data or a large number of components affect performance and risk hitting governor limits for view state, record limits, heap size and total page size.

5. Keeping Hardcoded programs

While Salesforce development works on improving the formula and keep the Apex code dynamic. Keeping hardcoded URLs can be disastrous if the environment gets changed. Thus, the concept of dynamic URLs is beneficial in the long run.

FAQs

  1. What are the most common Salesforce development mistakes?
    Ans. Some of the most common Salesforce development mistakes include writing non-bulkified Apex code, exceeding SOQL governor limits, using multiple triggers on the same object, hardcoding values, and ignoring performance and scalability early on. These issues often surface later as slow performance, failed deployments, or system errors in production.
     
  2. What types of mistakes occur in Salesforce development?
    Ans. Salesforce development mistakes usually fall into three areas: code quality, platform limits, and architecture decisions. Examples include running SOQL queries inside loops, not handling bulk data properly, poor trigger design, and building solutions without considering future scalability or maintenance.
     
  3. How can Salesforce development mistakes be fixed?
    Ans. Most Salesforce development mistakes can be fixed by following platform best practices early. This includes bulkifying Apex code, reducing unnecessary SOQL queries, using a single-trigger pattern, avoiding hardcoded values, and testing solutions with large data volumes. Regular code reviews also help catch issues before deployment.
     
  4. What are SOQL governor limits in Salesforce?
    Ans. SOQL governor limits are Salesforce-enforced limits that control how many database queries and records can be processed in a single transaction. These limits are designed to ensure fair usage of shared resources and prevent poorly written code from impacting overall system performance.
     
  5. What happens when SOQL governor limits are exceeded in Salesforce?
    Ans. When SOQL governor limits are exceeded, Salesforce stops the transaction and throws a runtime exception. This can cause data operations to fail, automation to break, and users to encounter errors. In production environments, repeated limit breaches can disrupt critical business processes.
     
  6. How can developers avoid hitting SOQL governor limits in Salesforce?
    Ans. Developers can avoid hitting SOQL governor limits by moving queries outside loops, using collections like maps and sets, retrieving only required fields, and designing Apex code to handle bulk data. Testing with large data sets helps identify limit issues early, before they affect users.
Hamir Nandaniya
About the author
Hamir Nandaniya

Hamir is the VP of Product at Maruti Techlabs. With his technical acumen and engineering expertise, he continues to overcome tough business challenges by building and scaling creative solutions.

Software Development Practices
Moving Your Call Center to the Cloud: A Step-by-Step Guide
Lure your business demands with agile technology combined with responsive decision making.
Mitul Makadia.jpg
Mitul Makadia
94409bec-improve-your-business-with-crm-and-cloud-telephony-integration.jpg
Salesforce Development
Improve your Business with CRM and Cloud Telephony Integration
Here's how you can manage your customer base in real-time using CRM and cloud integration.
Hamir Nandaniya.jpg
Hamir Nandaniya
How-Salesforce-can-make-your-startup-lean-1.jpg
Salesforce Development
How Salesforce Implementation Can Drive Lean Startup Success
Here are 5 common mistakes people make during salesforce development, so you can avoid them.
Hamir Nandaniya.jpg
Hamir Nandaniya
Going From Unreliable System To A Highly Available System - with Airflow
Case Study
Going From Unreliable System To A Highly Available System - with Airflow
Circle
Arrow