Monday, January 30, 2023

Salesforce: Field History Tracking for Activities

Activity in Salesforce is represented by Task and Event objects, they are special objects with a few limitations compared to other standard and custom objects, one of them being field tracking.

Before the Spring '23 release, you can't track field changes in the Activity, with community members creating and voting this in IdeaExchange that earned 33000+ votes.

The spring '23 release allows us to track activities fields history, with some limitations, but it is definitely a good starting. 

Navigate to the Task or Event object and click the "Set History Tracking" button and select up to 6 fields.

You can add the Activity Record History component from Lightning App Builder.

Here is the sample result in a Task:

Unfortunately, I don't see this yet in reporting, hope this will come in coming releases, or let me know if you see this. But you can query with API to object ActivityFieldHistory.

sample query: SELECT Id, ActivityId, ChangedBy.Name, FieldName, OldValueText, NewValueText  FROM ActivityFieldHistory 

I have no idea why the Ids are 000000000000000AAA, hope will see some explanation in the future.

For more information, looks for Event and Task History Considerations in this article Field History Tracking (as per Spring 23 release):

  • It can take up to a few minutes for changes to appear in history.
  • You can track up to six fields on events or tasks.
  • After an activity is deleted, the history for the activities can be visible via API queries for up to a few days. The history remains available because it’s deleted asynchronously from the activity.
  • Not all changes to recurring and child events are tracked.
  • You can’t delete specific field history records.
  • Bulk processes such as Bulk API transactions or event syncing can be delayed when field history tracking is enabled. If processes are delayed, consider turning off activity field history tracking.
  • The parent record of an activity is locked when the activity history updates. For example, if an activity is linked to thousands of accounts, each account is locked while the history updates. As a best practice, avoid data skew. If processes fail because of parent-child row locking, consider turning off activity field history tracking.
  • Field value changes caused by process builder, Apex triggers, or flows are tracked in an activity’s history. Users see the change only if their field-level security settings permit them to. In other objects, field changes from processes, triggers, and flows are tracked only if the current user has permission to edit the modified fields.
  • If a previously encrypted field used for tracking is unencrypted, the values tracked while the field was encrypted don’t appear. After the field is unencrypted, the values are tracked in history.
  • Activity history is available in APIs only for admins with permission to modify all data.
  • For activities, field history is shown in a Lightning component that looks like a related list. Instead of managing the history on the page layout, you place the Activity Record History component on Lightning pages for event and task records. You can add the Activity Record History component to custom event and task pages or remove it from the default pages. The history list stays empty until you turn on field history tracking in the Object Manager.
  • The history list isn’t available in Salesforce Classic or in the mobile app.


Wednesday, January 4, 2023

Salesforce: Object tab visibility in App

A tab of an object is very useful and increases user daily productivity with fewer clicks, the tab will be visible in an app based on multiple settings, let's dive into it.

First, for a user to able to see the tab, the user must have access to the object via Profile or Permission Set. 

Default tab -- this mean, the tab will be always visible to the user, and users can't remove it from the Lightning app, the user will not see the cross icon when clicking the pencil icon from the navigation bar.

Users will not able to remove the Home tabs until the Chatter tabs

The criteria to make a tab become a default tab:

  1. The user must have permission to access the object via Profile or Permission Set, and
  2. The tab is added to the Navigation Items for the app in the Lightning App Builder, and
  3. The tab is set to Default On in the Profile, or "Visible" is checked from Permission Set

If (2) or (3) is changed, the tab will be removed if a user has not customized the navigation items, but if the user has customized (rearrange) the navigation items, the tab will stay, but the user will be able to remove the tab by clicking the pencil icon from the navigation bar, see this blog for detail.

Not default tab
-- the example from the above screenshot is "Glass", where the tab is removable. To make this happen, here are the requirements:

  1. The user must have permission to access the object via Profile or Permission Set
  2. The tab is set to Default Off in the Profile, or only "Available" is checked in the Permission Set, no matter whether it is added or not in the lightning app Navigation Items. 

The user should be able to search the tab from the 9-dots icon.


Monday, January 2, 2023

SimplySfdc in 2022

Happy new year 2023! This also meant that SimplySfdc has shared tips and knowledge related to Salesforce for 11 years, with more than 650+ blogs, what an incredible journey!

As per tradition, this blog will share some statistics of SimplySfdc in 2022 -- here is the statistic for 2021.

In 2022, fewer blog posts were written, but total pageviews and sessions were almost similar to 2021.

Page 2022 2021 2020 change*
Total New Page 37 50 29 -26.00%
Total Pageviews 1,038,945 971,076 305,957 6.99%
Total Sessions 485,794 491,048 271,214 -1.07%
Pages / Sessions 2.14 1.98 1.13 8.08%
* compare 2022 to 2021

In 2022, direct access to the blog increased by more than 57%, while traffic from searches was down by 4% compared to the previous year. Both referral and social which were pretty low in 2021 are getting lower in 2022.

Channel Source 2022 2021 2020
1. Organic Search 85.04% 88.58% 82.86%
2. Direct 12.29% 7.78% 13.73%
3. Referral  2.27% 2.88% 2.69%
4. Social 0.39% 0.75% 0.71%

Again, traffic from Google getting lower, and from Bing is increasing over the years, although, it has not created a lot of impacts yet.

Top Search Engine 2022 2021 2020
1. Google 94.35% 95.94% 96.85%
2. Bing 4.84% 3.19% 2.12%
3. Yahoo 0.34% 0.27% 0.44%
4. Other 0.47% 0.59% 0.58%

Except for Germany, which also jump from #7 in 2021 and 2022 to #5 in 2022, all top 6 countries contribute lower traffic. The gap between the United States and India getting closer with only a 6+% difference. One note from this insight is, more countries are accessing because is used by more countries.

Top Visitor Country 2022 2021 2020
1. United States 32.93% 35.06% 37.27%
2. India 26.57% 27.40% 25.20%
3. United Kingdom 4.63% 4.88% 4.78%
4. Canada 3.30% 3.34% 3.09%
5. Germany 2.76% 2.08% 2.18%
6. Australia 2.56% 3.05% 3.03%
* Germany was #7 in 2021 and 2020
* Australia was #5 in 2021 and 2020
* France was in #6 in 2021 and #8 in 2020

From the cities' perspective, the top 5 cities are still the same as in 2021. Most familiar cities still appear in the top 6 cities. New York resurfaces back to #6 from #7 in 2021. All top 6 cities (except Bengaluru) contribute a lower percentage compared to 2021. The top 6 cities represent 13.32% of the total visitors, which is a bit lower than in 2021 where the top 6 cities contribute 13.54%. 

Top Visitor Country 2022 2021 2020
1. Hyderabad 3.66% 3.67% 3.86%
2. Bengaluru 3.05% 2.88% 3.80%
3. Pune 2.07% 2.13% 2.38%
4. London 1.59% 1.66% 1.86%
5. Mumbai 1.48% 1.61% 1.36%
6. New York 1.47% 1.49% 1.45%
* Mumbai was #7 in 2020
* New York was #7 in 2021 and #6 in 2020
* Chennai was in #7 in 2022 and #6 in 2021

This statistic includes access from desktop and mobile. Total top 5 web browsers contribute almost  99% of the visitors. Chrome again proves as the default web browser for everyone, and although it is on a downtrend, this may mean something for Chrome for its market domination. Edge shared is kept higher, while the rest are lower compared to 2021.

Top Visitor Web Browser 2022 2021 2020
1. Chrome 86.05% 86.94% 88.78%
2. Edge 6.94% 5.20% 2.64%
3. Safari 3.49% 4.02% 3.13%
4. Firefox 2.15% 2.65% 3.10%
5. Opera 0.29% 0.37% 0.30%

In terms of the operating system, there is no change in the top 5 operating systems. Windows users decreased by more than 3%, and Android shows a bigger jump to more than 8%. Traffic from mobile and tablet users increase quite significantly to 12.60%.

Top Visitor Operating System 2022 2021 2020
1. Windows 66.24% 70.01% 70.59%
2. Macintosh 19.81% 20.31% 19.57%
3. Android 8.39% 4.84% 5.16%
4. iOS 3.21% 3.41% 2.80%
5. Linux 1.57% 0.92% 1.34%


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 51%. 
The resolution of 1920x1080 is the standard for most users, and more users move to WQHD (2560x1440) resolution.
Top Visitor Screen Resolution 2022 2021 2020
1. 1920x1080 25.07% 26.26% 24.34%
2. 1280x720 15.69% 14.86% 12.65%
3. 1536x864 10.65% 10.99% 10.44%
4. 1366x768 8.14% 11.40% 15.14%
5. 1440x900 6.42% 7.45% 8.03%
6. 2560x1440 3.77% 3.65% 3.05%


Top 5 Popular Page

3 out of 5 top pages from 2021 reappear in 2022. A very old blog written in 2013 took the top spot #1 in 2021 and again in 2022 with a record high of more than 35K hits in 2022 alone. Two new blogs written in 2021 appear as #2 and #5.

1. Salesforce: ISBLANK() or ISNULL() ~ 35,399 hits [2013] (#1~2021; #2~2018; #3~2017; #1~2016; #2~2015; #3~2014)
2. Salesforce: Email Template with Hyperlink ~ 24,547 hits [2021] (new blog)
3. Salesforce: EmailMessage object ~ 17,599 hits [2020] (#4~2021)
4. Salesforce: Convert ID from 15 to 18 characters with Excel formula ~ 17,055 hits [2018] (#2~2021; #2~2020; #3~2019)
5. Salesforce: Export Query Result from Developer Console ~ 15,735 hits [2021] (new blog)

I'll skip the detail of traffic from both referral and social as their total traffic contribute less than 2.7%.



Monday, December 12, 2022

Salesforce: Using Formula Field

The formula field is one of the best features of the Salesforce platform for admin (and developer). Despite the limitation and restrictions, it still serves a lot of benefits. 

Some restrictions:

  • You can’t use long text area, encrypted, or description fields in formulas.
  • The value of a field can’t depend on another formula that references it.
  • You can’t delete fields referenced in formulas. Remove the field from the formula before deleting it.

But, where the formula field can and cannot be used?

Page Layout - Yes, including dynamic form, search layout, and compact layout. But the formula field is not searchable.

Report - Yes, including use as a filter

List View - Yes, including use as a filter

Validation Rule - Yes, except that you can't set the error message location at a formula field

Approval Process - Yes

Sharing Rule - No, the criteria based sharing rule does not support by formula field, you can vote on the idea here, here, and here; here is the original idea but has been marked as partially delivered although the item delivered has nothing to do with sharing rule.

Email TemplateYes


SOQL - Yes

If there are other places we can or cannot use formula fields, feels free to comment below this blog. 


Monday, November 28, 2022

Salesforce: Email-to-Case and EmailMessage object

Two years back, we shared about the EmailMessage object here, this blog will share the relationship between how the email is stored in the EmailMessage with email-to-case.

This blog is written for email header-based threading, not the older string-based threading, check out the difference here.

Email Header

Outlook Email Properties

There are 3 main pieces of information from the email header that determine email header-based threading.
  1. Message-ID: this is a unique Id from each email sent.
  2. In-Reply-To: when someone reply, reply all, or forward email, this will be the Message-ID of the email replied or forwarded -- this will be not available for a brand new email
  3. References: this will contain ALL Message-ID in the past related to the email, because of the the email is replied or forwarded -- this will be not available for a brand new email
Email header example in Outlook:

Another sample from Gmail:
<> <>


ThreadIdentifier is a field in the EmailMessage object that will be auto-populated when sending emails or receiving emails to Salesforce, including manually logged emails.

For email-to-case, ThreadIdentifier is the Message-ID of the 1st email sent by a user as a brand new email (not reply/forward), and that email possibility not be sent to the email-to-case email address alias yet.

- A send email to B [Message-ID = A123]
- B replies A, and also cc to email-to-case email address [Message-ID = B888]
ThreadIdentifier in this scenario is A123, even though A did not send the email to the email-to-case email address. 

Email-to-Case Threading

As per this article, there are 2 main points that determine if an email sent to email-to-case alias will create a new case or be attached to an existing case:

  1. Looks for "MessageIdentifier" in the Salesforce EmailMessage object to match with the "In-Reply-To" email address in the email header, if not found, continue to (2) 
  2. Looks for "MessageIdentifier" in the Salesforce EmailMessage object to match with the "Reference" email address in the email header 

If found, link that email to the case by looking at ParentId (which is Case Id) from the matching record of the EmailMessage object. So, the matching here is not based on ThreadIdentifier. 

First scenario:
1. A create a brand new email and send it to B and C
2. B reply all and forward the email to
3. C reply all and forward the email to

The above scenario will create 2 cases:

  • with the same ThreadIdentifier, but MessageIdentifier generated from email B (2) and email C (3) is different
  • all references in the following emails will not contain the original email A (1) in their reference, so these 2 cases will be continuously run independently.

Second scenario:
1. A creates a brand new email, sends it to B, also to and 
2. B reply all

What will happen from the above scenario:

  • The first email from A will generate 2 cases with the same MessageIdentifier
  • When B hit reply all, there are 2 streams of email reaching Salesforce, and both looking for the same MessageIdentifier, the system will simply attach the email to any of these 2 cases, but from my trail, these 2 streams' of email are attached to the last cases created. so there will be 3 emails in the last case created

Third scenario:
1. A creates a brand new email and sends it to B, also to  
2. B reply all and add

What will happen from the above scenario:

  • The first email from A will generate 1 new case
  • When B hit reply all and adds new email alias linked to email-to-case, the "In-Reply-To:" in the second email will point to the Message-ID of the first email which is the MessageIdentifier for the case created in the first email, so there will be no new case created here

Sample querySelect ParentId, CreatedDate, Status, Subject, FromAddress, ToAddress, CcAddress, MessageIdentifier, ThreadIdentifier, Id, ReplyToEmailMessageId from EmailMessage where CreatedDate = Today


Saturday, November 26, 2022

Salesforce: Send List Email (3)

his is to continue Salesforce: Send List Email and Salesforce: Send List Email (2) written months ago. 

You can send mass email to a maximum of 5,000 external email addresses per day per licensed Salesforce org based on Greenwich Mean Time (GMT), and sending email from list view is considered as mass email. For example, if you have in your email 10 times that counts as 10 against the limit.

You can send mass emails only to contacts, person accounts, leads, and your internal users. 

You can send an unlimited amount of emails through the Salesforce UI to your internal users, which include portal users.

To mass email from the list view:

  1. Select/create the list view
  2. Select the contacts/leads checkbox
  3. Click the "Send List Email" button, if you do not see the button, make sure the button is added to the list view and you have "Allow sending of List Emails" permission, see this blog for detail.

In the Send List Email window

  • You will see the balance of send email limit remaining
  • You can select "From" based on your setup, including Organization-Wide Email Addresses
  • You can use an email template, merge fields, and attach files
  • You can Send Later and Save as Draft
  • Each recipient will only see their name as the recipient, not the whole recipient's name

Tips: to see your draft email, looks for "List Email" from the 9-dots icon


Page-level ad