Pages

Wednesday, July 24, 2024

Navigating Salesforce's Governor Limits (Part-1)

I assume many of us have at least once encountered this type of error or a similar one: ‘DeleteCaseTrigger: System. LimitException: Too many query rows: 50001’. This error means that you have just hit the Salesforce Governor limits in your Salesforce org. These limits are key to Salesforce development, ensuring the platform stays efficient and reliable even with many users accessing it at once. But what exactly are Governor Limits, and why are they so important?

Governor Limits are rules set by Salesforce to keep shared resources in the multi-tenant environment healthy. Since Salesforce uses a shared infrastructure where multiple organizations (tenants) use the same instance, these limits prevent any single tenant from hogging resources. This ensures fair resource distribution, optimal performance, and system integrity.


Understanding and respecting these limits is crucial for developers. Ignoring them can lead to failed transactions and poor performance, ultimately affecting the user experience. In essence, Governor Limits are Salesforce's way of enforcing best practices and encouraging developers to write efficient, scalable code.


Governor Limits may seem restrictive at first, but they play a vital role in maintaining a balanced and high-performing ecosystem and different implementations, such as Salesforce Commerce Cloud implementation. In the following sections, we'll explore what these limits involve, the challenges they present, and how developers can effectively manage and work within them.

Insight:  

You can encounter the limit error not only when compiling your code but also in other automation, such as Salesforce Flow.


Salesforce Governor Limits error in the Salesforce Flow example

Understanding Governor Limits

To effectively handle Governor Limits in Salesforce, it's important to understand what they are and the various types that exist. AppExchange consultants are professionals who can assist in managing these limits efficiently. In this section, I’ll try to explain Governor Limits and categorize them to help you understand their scope and application.

Types of Governor Limits

Apex Execution Limits

Apex execution limits ensure that no single process consumes too many resources, protecting the overall system performance. These limits include:

  • SOQL Queries: Apex limits the number of SOQL queries that can be executed in a single transaction to 100 for synchronous transactions and 200 for asynchronous transactions. For example, if an Apex class tries to execute 101 SOQL queries in a synchronous transaction, it will fail.

  • CPU Time: The maximum amount of CPU time allocated for an Apex transaction is 10,000 milliseconds for synchronous transactions and 60,000 milliseconds for asynchronous ones. This prevents any single transaction from overloading the server.


DML Operations Limits

These limits control the number of data manipulation language (DML) operations that can be performed within a single transaction:

  • DML Statements: The limit for DML statements (insert, update, delete, etc.) is 150 per transaction. This means that if a process tries to perform 151 DML operations, it will be stopped, and an error will be thrown.

  • Records Processed: A single transaction can process up to 10,000 records via DML operations. This ensures that large data operations do not hinder system performance.


Callout Limits

Apex limits the number and duration of external web service callouts to ensure balanced usage:

  • Number of Callouts: Each transaction can include up to 100 callouts (HTTP requests or web service calls). This helps maintain the availability of external services.

  • Callout Time: The cumulative timeout for all callouts in a transaction is 120 seconds. This prevents long-running callouts from blocking system resources.


Heap Size Limits

The heap size limit governs the amount of memory allocated to an Apex transaction:

  • Heap Size: The heap size limit is 6 MB for synchronous transactions and 12 MB for asynchronous transactions. This helps control the memory usage of complex or large-scale processes.


Email Limits

Salesforce controls the number of emails that can be sent to prevent misuse:

  • Single Email Messaging: The limit for single email messages is 10 per transaction, ensuring that email services are not overloaded.

  • Mass Email Messaging: Limits also exist on the number of mass emails that can be sent, managing server load and preventing spam.


API Limits

These limits ensure fair usage of the Salesforce API:

  • API Calls: Each Salesforce org has a daily limit on the number of API calls it can make. This prevents any single org from overloading the system.

  • Concurrent API Calls: There are also limits on the number of concurrent API requests, which helps to prevent server overload.


Platform Event and Streaming API Limits

These limits control the usage of platform events and streaming APIs:

  • Event Delivery: There is a cap on the number of platform events that can be delivered in a transaction, ensuring that the event processing system is not overwhelmed.

  • Streaming API: Limits exist on the number of push topics and the number of clients that can be connected simultaneously to the Streaming API, maintaining balanced system performance.


Storage Limits

Salesforce imposes limits on both data and file storage to manage resources effectively:

  • Data Storage: Each org has a limit on the amount of data that can be stored, which varies by Salesforce edition. This ensures that storage resources are used efficiently.

  • File Storage: Similarly, there are limits on the amount of file storage available, including attachments and documents.


Why Understanding These Limits Matters

Knowing and understanding these various Governor Limits is crucial for Salesforce developers. It allows them to design applications that are efficient and comply with Salesforce's resource management policies. By adhering to these limits, developers can avoid runtime exceptions and performance issues, ultimately providing a smoother user experience.

Salesforce Governor Limits error in the Apex code example


Wrapping Up

Navigating Salesforce's Governor Limits is important for building efficient and reliable applications on the platform. Understanding the different types of Governor Limits — such as SOQL query limits, DML operation limits, CPU time limits, heap size limits, and API call limits — is essential.

These limits help keep the system running smoothly by preventing any one user or application from hogging resources. Although these limits can seem restrictive, they are designed to ensure fair resource distribution and maintain system performance.


To be continued...


This is a guest blog post by: Dorian Sabitov



Monday, May 20, 2024

Salesforce: Target Object for Create a Record Action Type

We discussed in an earlier blog that we can use an action to "find" a child object; however, for a child object with multiple parent objects, the object may not be available for selection as a Target Object in “Create a Record” quick actions.

Salesforce does not allow to create the actions to related child entity when we have multiple relations of different types to the child entity. 

For Example:

Custom objects A-B with Master-Detail relationship and custom objects A-C with Master-Detail relationship too --> create quick action “Create a Record” on A, you will see both B and C as target objects.



Custom objects D-E with a Master-Detail relationship and custom objects F-E with a Lookup relationship, too --> create a quick action “Create a Record” on D; you will see E as the target object, but create a quick action “Create a Record” on F; you will NOT see E as the target object.


* blue line = Master-Detail and red line = Lookup relationship


Now, change the D-E objects relationship to Lookup, and you will see E as the target object from both D and F.



If you change both the D-E and F-E relationships to Master Detail, you will see E as the target object from both D and F too.






Reference

Friday, May 17, 2024

CRM Analytics: Recipe and Dataflow case sensitive

Key in join node in CRM Analytics is case-sensitive, sample:



The same applies to the augment node in the dataflow; the key is case-sensitive too, sample:
 

 

Thursday, May 2, 2024

Salesforce: Custom Object without Tab

It's easy to create a custom tab to create a new record of an object from UI; however, in some scenarios, we (admin) are not supposed to create a custom tab, so how to enter new data from the UI, or to see data created (I know we can use report if that object is enabled for reporting) in UI.

Create a New Record
https://domainname.lightning.force.com/lightning/o/objectname__c/new

View Record in the List View
https://domainname.lightning.force.com/lightning/o/objectname__c/list?filterName=Recent
Once you have landed in the list view, you can create a new list view with filters to see the data as needed.



Tuesday, April 23, 2024

CRM Analytics: Recipe syntax

Every computer language has its own syntax, the same with query language or formula. Here are the samples of SAQL that are used in Dataflow.

 Since CRM Analytics is moving with Recipe, here are samples of the formula syntax in the Recipe:

String - use '  ', e.g., 'Singapore'

Field name - use "  ", e.g., "Account.Id", optional if the field name does not contain dot(s)

Field with blank value - "Opportunity.Id" IS NULL

CASE, e.g., case when Have_Activity = 'Yes' or Have_Opportunity = 'Yes' then 'No' else 'Yes' end

IN with (), e.g.,
case when Type in ('Customer', 'Other') then 'A'
        when Type in ('Customer - Direct', 'Customer - Channel') then 'B'
        else 'C' 
end

Logical Function
use or, and, e.g., case when Have_Activity = 'Yes' or Have_Opportunity = 'Yes' then 'No' else 'Yes' end

Compare Operator
use != (not <>) as compare operator, also use = (not ==), e.g., Have_Activity != 'Yes'

Current and Previous Quarter
case 
    when quarter(now()) = 2 and (year(now()) = year(LastActivityDate)) then 'Yes' 
    when quarter(now()) = 3 and (year(now()) = year(LastActivityDate)) and (quarter(LastActivityDate) in (2,3)) then 'Yes' 
    when quarter(now()) = 4 and (year(now()) = year(LastActivityDate)) and (quarter(LastActivityDate) in (3,4)) then 'Yes' 
    when quarter(now()) = 1 and ((year(now()) = year(LastActivityDate)) or (quarter(LastActivityDate) = 4 and year(LastActivityDate) = year(now()) -1)) then 'Yes'
    else 'No'
end


Do you have a great formula to share? Feel free to add in the comment.




Friday, April 19, 2024

CRM Analytics: Adding Salesforce Action in CRM Analytics

Here is the step:

1. Create Salesforce Action --  navigate to Salesforce's object manager, look for the object, click on Buttons, Links, and Actions menu, then click New Action.

2. Add the newly created Action to a Salesforce page layout (this is a must).

3. Configure the Action from the CRM Analytics dataset. 



Once configured, if you have a table widget in the dashboard, you can also set up one-click actions, so by clicking the value, the action selected will be performed, e.g., click the value in Account Name to call the action to edit Industry.




Reference:

  



Thursday, April 18, 2024

Salesforce: Public Read/Write Access




What does Public Read/Write access mean for a user? This means all users can view and edit all records for that object, but only when the user has permission to access the object (minimum read access). The object permission can be set in Profile or Permission Set assigned to the user.

For example, if Tom is the owner of Trident Inc.'s record, all users can view and edit it. However, only Tom can change the owner or delete (if he has Delete permission given via Profile or Permission Set) the Trident Inc. record.


Scenario:

1. User Profile (and Permission Set) does not have access to the object

  • Unable to access any records
  • Unable to own records from the object 


2. User Profile (or Permission Set) has Read access to the object

  • Able to own records 
  • Able to access records owned by any users


3. User Profile (or Permission Set) has Edit access to the object

  • Able to own records 
  • Able to edit records owned by any users
  • Not able to change record owner, only record owner (and users above the role hierarchy if Grant Access Using Hierarchies is enabled for custom objects; Grant Access Using Hierarchies is always enabled for standard objects)


4. User Profile (or Permission Set) has Create access to the object

  • Read access will be auto-enabled
  • Able to create records 


5. User Profile (or Permission Set) has Delete access to the object

  • Read and Edit access will be auto-enabled
  • Able to delete records owned
  • Delete permission does not roll up to users above the role hierarchy; even the Grant Access Using Hierarchies is enabled 


So, in other words, View All permission is replaced with Read permission, while Edit All permission is replaced by Edit permission. 


Note: Profile permission access does not roll up to user by Role Hierarchy


Reference




Wednesday, April 17, 2024

Salesforce: Finding Child Objects

As a Salesforce admin, seeing the parent objects of an object is easy; just go to the Object Manager, look in Fields & Relationships, and look for fields with type = Lookup or Master-Detail.

However, the other way around, looking for child objects from an object is not straightforward; developers can use getChildSObject()

Here is a way to find child objects, which is using Workbench.

Navigate to Standard & Custom Objects, choose the object, and see items under "Child Relationships"  


The one with cascadeDelete = True is the Master-Detail relationship, while cascadeDelete = False is the Lookup relationship.

Another way to look for custom child objects is by creation action and selecting "Create a Record"




If you know any other ways, feel free to comment.



Tuesday, April 9, 2024

Email Composers in Email-to-Case

Salesforce is transitioning email editor for Case (to be clear, this is not for email in other standard or custom objects) to a modern editor based on HTML 5.
 
Existing Case Email Composer


New Case Email Composer


The new editor provides new features, including:
  • Full-screen mode
  • Printing
  • Undo and Redo buttons
  • Format painting
  • Emoji picker
  • Resizability
  • A more responsive toolbar
  • Smart copy-paste functionality
Large recipient lists are no problem now that you can drag—or copy and paste—recipients' email addresses, attachments, and inline images.

You can manually transition to the new editor by navigating to Release Updates in the setup menu and looking for Transition to the Lightning Editor for Email Composers in Email-to-Case. As per the current timeline, this needs to be completed before 1st Sep 2024.



Reference:

Friday, February 16, 2024

Salesforce: Salesforce Authenticator Re-Registration

Background: A Salesforce user uses Salesforce Authenticator for MFA; however, the account is removed by accident by mistake, or the app is deleted, or user has a new phone. So, when the user login to Salesforce, the user will get the following popup from the Salesforce Authenticator app. 



Solution: The admin can simply go to the user detail and disconnect "App Registration: Salesforce Authenticator".


Once disconnected, when user login again with username and password, the system will ask the user to add an Account in the Salesforce Authenticator.


Reference:




Monday, January 15, 2024

CRM Analytics: Sync Widget to other Layouts

In the previous blog, we shared that you can manually add widgets that have been added in other layouts. Since then, CRM Analytics has a new feature to enable sync between layouts, which means that when you add a new widget, it will be added to other existing layouts automatically. The same when you delete widgets from a layout; it will be deleted in other layouts too.

Click Manage Layouts from the layout dropdown and make sure Sync is enabled.



Widgets synced to other layouts will be added randomly in other layouts.


Reference:


Monday, January 8, 2024

SimplySfdc in 2023

Because Google Analytics changed recently, and the changes need to be setup correctly for the blog. However, I just realized something was wrong in early December 2023, so the traffic data captured is only for 4-31 December 2023, so some of the statistics will be ignored.

New Page 2023 2022 2021 change*
Total New Page 21 37 50 -43.24%
* compare 2023 to 2022


Channel Source 2023 2022 2021
1. Organic Search 86.97% 85.04% 88.58%
2. Direct 10.47% 12.29% 7.78%
3. Referral  2.31% 2.27% 2.88%
4. Social 0.25% 0.39% 0.75%


Top Visitor Country 2023 2022 2021
1. United States 33.08% 32.93% 35.06%
2. India 28.73% 26.57% 27.40%
3. United Kingdom 4.76% 4.63% 4.88%
4. Canada 3.35% 3.30% 3.34%
5. Germany 2.31% 2.76% 2.08%
6. France 2.31%

* Australia was #6 in 2022 and #5 in 2021
* Germany was #7 in 2021
* France was #6 in 2021


Top Visitor City 2023 2022 2021
1. Hyderabad 5.62% 3.66% 3.67%
2. Mumbai 3.29% 1.48% 1.61%
3. Chennai 3.24%

4. Bengaluru 2.87% 3.05% 2.88%
5. London 2.29% 1.59% 1.66%
6. Pune 2.14% 2.07% 2.13%
* Mumbai was #5 in 2022
* Chennai was in #7 in 2022 and #6 in 2021
* Bengaluru was in #2 in 2022 and #6 in 2021
* London was #4 in 2022
* Pune was #3 in 2022 


Top Visitor Web Browser 2023 2022 2021
1. Chrome 87.52% 86.05% 86.94%
2. Edge 8.40% 6.94% 5.20%
3. Safari 2.22% 3.49% 4.02%
4. Firefox 1.49% 2.15% 2.65%
5. Opera 0.29% 0.29% 0.37%


Top Visitor Operating System 2023 2022 2021
1. Windows 69.54% 66.24% 70.01%
2. Macintosh 21.55% 19.81% 20.31%
3. Android 4.36% 8.39% 4.84%
4. iOS 2.13% 3.21% 3.41%
5. Linux 1.09% 1.57% 0.92%


As mentioned in the previous year's blog, a screen resolution of 1536x864 probably is 1920x1080 resolution with the display set to 125% zoom, and 1280x720 is 150% zoom of 1920x1080, so in total, 1920x1080 contributes to more than 55%. 
The resolution of 1920x1080 is the standard for most users, and more users move to WQHD (2560x1440) resolution.

Top Visitor Screen Resolution 2023 2022 2021
1. 1920x1080 26.95% 25.07% 26.26%
2. 1280x720 16.30% 15.69% 14.86%
3. 1536x864 11.93% 10.65% 10.99%
4. 1366x768 6.48% 8.14% 11.40%
5. 1440x900 5.42% 6.42% 7.45%
6. 2560x1440 4.39% 3.77% 3.65%


Top 5 Popular Pages

Three out of 5 top pages from 2022 reappear in 2023. It is still shocking when there are two-decade-old blogs still appear as top pages in 2023:
4. Salesforce: ISBLANK() or ISNULL() [2013] (#1~2022; #1~2021; #2~2018; #3~2017; #1~2016; #2~2015; #3~2014)

Two top blogs in 2022 now drop to #6 and #7
7. Salesforce: EmailMessage object [2020] (#3 in 2022; #4~2021)



Reference:


 

Salesforce: Natural Language Search filter

Search is one of the most use functions in Salesforce; it allows users to search almost anything for data that a user can see, as long as it is configured correctly and not a formula field; check out this blog.

Additionally, Einstein Search also allows you to search using Natural Language Search for core standard objects: 

  • Account
  • Case
  • Contact
  • Lead
  • Opportunity
  • Task
Natural language search isn’t case-sensitive, and you can use singular or plural, such as account and accounts, which will return the same result; using "my" will return all records that you own, such as my account.

Before that, make sure that you enable "Actionable Instant Results" and "Natural Language Search" under Einstein Search Settings in the setup menu.


Note: Einstein Search is not available in Developer Edition, as per this article.

Here are a few search terms that are practical for your user:
  • my account
  • my open opportunity
  • my open opportunity created last week
  • my open task
Check out this article for complete samples.


Adding Natural Language Search filters
On the same settings page, you also can enable "Natural Language Search filters", check out this article for more information about the filter.



Here is the sample result, where you can change the filters. Notice that the system now shows the filters applied as drop-down, compared to the 1st screenshot, where it just shows a description of the filters "Owner Johan Yu • Object Account • Billing State/Province Ny • Office State/Province Ny | Sorted by Last Modified Date".





Reference:


Page-level ad