Posts

Salesforce Fact #949 | If-else statement in lightning email template

Image
We can add if/else condition in Lightning Email template to some extent. In this example, We are showing the Account rating in the template if the parent account is present. Reference:  https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007ifdqr Attached is the screenshot.

Salesforce Fact #948 | Prevent login using Transaction Security Policy

Image
We can use transaction security policy to prevent multiple users from logging into Salesforce. To implement this, we use the LoginEvent, an apex class and custom permission set. In this example, we have created a permission set 'Prevent Login PS' and in the apex class we are checking whether the user is assigned the PS or not. Note: Custom permission check does not work because in that case the context user is Automated user, not the intended user. Reference:  https://salesforce.stackexchange.com/questions/387530/featuremanagement-checkpermission-not-returning-expected-result Attached are the screenshots.

Salesforce Fact #947 | Resolving dashboard logged-in user limit error

As we know there's a limit on the number of dashboards with the option to run as the logged-in user, the below queries are useful while troubleshooting and resolving the error: SELECT FolderName,Title FROM Dashboard WHERE Type = 'LoggedInUser' OR Type = 'MyTeamUser' -> This will fetch the list if dynamic dashboards present in the org SELECT Id,Title FROM Dashboard WHERE Type != 'SpecifiedUser' -> This will return dynamic dashboards that are not in private folders.  SELECT Id,Title FROM Dashboard USING SCOPE allPrivate WHERE Type != 'SpecifiedUser'  -> This will return dynamic dashboards that are in private folders. Reference:  https://help.salesforce.com/s/articleView?id=000385369&type=1

Salesforce Fact #946 | Constructing dynamic SOQL using dynamic formula evaluation

Image
With Summer'25 release, Dynamic formula evaluation is possible using  FormulaBuilder.parseAsTemplate() method and merge field syntax. This approach can be used to construct Dynamic SOQL queries. In this example, we are trying to fetch Account records which are matching with a Lead ownerid and Leadsource. Reference:  https://developer.salesforce.com/blogs/2025/05/summer25-developers Attached is the screenshot.

Salesforce Fact #945 | PathAssistant Sobject

There is an Sobject 'PathAssistant' in the Tooling API which we can query to get the list of all paths in the org. Few things to note: 1) If we include the FullName field in the query, we need to make sure the query returns 1 row else we encounter an error. 2) SobjectProcessField denotes the picklist field for which the path has been setup. Reference:  https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_pathassistant.htm

Salesforce Fact #944 | Getting record id in utility bar LWC

If we have an LWC component in the utility bar, we can get record id in the context of a record detail page. For this, we need to check if CurrentPageReference type is standard__recordPage. Reference:  https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_js_lightning_utility_bar_page_context.htm

Salesforce Fact #943 | Get execution context using Quiddity Enum

Sometimes we need to know the context of the execution event of the apex code, whether it is called from UI, anonymous window, data load, batch apex etc. System class provides a Quiddity enum with all the possible values of execution contexts. It can be figured out by calling System.Request.getCurrent().getQuiddity(). For example, If the apex code is invoked from the anonymous window, it returns ANONYMOUS. If the apex code is invoked from any data load using import wizard or Data loader(with Bulk API enabled), it returns BULK_API. Check out the full list of values:  https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_enum_System_Quiddity.htm