Posts

Showing posts from October, 2022

Salesforce Fact #547 | VF email template restriction

In VF email template, the messaging:htmlEmailBody and messaging:plainTextEmailBody tags can appear only once within a template. So, if we need to render some content in the email template dynamically, we can put conditional rendering on the content inside these tags.

Salesforce Fact #546 | CopytoClipboard in LWC

Image
We can implement CopytoClipboard feature in LWC using bit of logic. Reference:  https://salesforce.stackexchange.com/questions/272371/interacting-with-the-browser-clipboard-from-lwc Attached are the screenshots.

Salesforce Fact #545 | $UserRole in formula

We can use $UserRole global variable in formula field and validation rule to get the role of the current user, Similar to flow. However, the ' ParentRoleId ' field is not accessible in formula.

Salesforce Fact #544 | IsProfilePhotoActive

How to check whether the profile photo is set for the user. There is a field named ' IsProfilePhotoActive ' in User object which is true when the profile photo is set, else it is false. Reference: https://developer.salesforce.com/docs/atlas.en-us.238.0.object_reference.meta/object_reference/sforce_api_objects_user.htm

Salesforce Fact #543 | Required field in dynamic forms

While migrating fields from layout to dynamic form, if any universally required field was not present in the layout it is migrated from, it is not migrated automatically. For example, in Opportunity page layout the universally required field Forecast Category is not present and while migrating the fields to dynamic form, we get an error message saying a required field is missing in the layout and the user won't be able to save any record. Reference:  https://trailhead.salesforce.com/content/learn/projects/convert-a-lightning-page-to-dynamic-forms/get-started-with-dynamic-forms

Salesforce Fact #542 | Activate order/contracts permission check LWC

Image
We can check whether the current user has access to activate order and contracts using the userPermission module in LWC. Attached is the screenshot.

Salesforce Fact #541 | Flow check if older version is active

Do you know there is a field in Flow list view called 'Is Using an Older Version' which denotes whether the latest version is active. If any previous version is active, this flag is true. We can filter on this flag to quickly figure out which all flows are having any previous version activated.

Salesforce Fact #540 | Creating task for a lead record

Do you know while creating a task associated to a lead record it is not possible to select any other record in the 'Related To' field. Attempting to do so generates the error: ' You can’t relate an account, opportunity, or other object to a task already related to a lead. ' Reference:  https://help.salesforce.com/s/articleView?id=000388265&type=1

Salesforce Fact #539 | FLS on component visibility with multiple filter conditions

In continuation of the last post, the FLS is respected in case of multiple filter conditions as well.  For example, if the component visibility filter is based on the rating and industry fields of account and if the user has access to only industry field, in that case the filter would not be applicable and the component would not be visible, Even if the condition is using 'OR'.

Salesfore Fact #538 | FLS on component visibility

Component visibility option on lightning app builder respects the FLS of the user. If the visibility filter contains some field which is not accessible to the user, the component remains invisible to the user. For example, in the Account record page there is a component visibility filter based on the rating field value of account. Now, if the rating field is not accessible to any user, the component would not be visible to that user.

Salesforce Fact #537 | Contact & Lead email opt out

There is a checkbox field ' HasOptedOutOfEmail ' in Lead and Contact which specifies the lead's or contact's opt in or opt out choice of receiving email.  If the checkbox is true and an attempt is made to send the email to lead or contact, the error: ' This person opted out of commercial email ' is encountered.

Salesforce Fact #536 | Current component name in LWC

We can get the current component name in same LWC using the syntax: this.template.host.localName . It returns the component name in the format: <namespace>-<componentName> considering the Kebab case. Reference:  https://salesforce.stackexchange.com/questions/326166/can-an-lwc-component-get-its-own-name

Salesforce Fact #535 | HasOverdueTask & HasOpenActivity

Do you know there are two fields ' HasOverdueTask ' and ' HasOpenActivity ' in Opportunity. These two fields denote whether the opportunity has any overdue task or any open activity respectively. The FLS for these fields cannot be granted and they are only accessible through the API. Reference:  https://help.salesforce.com/s/articleView?id=000383161&type=1

Salesforce Fact #534 | messageData in ShowToast LWC

Do you know there is an attribute named ' messageData ' in ShowToastEvent in LWC which can replace the placeholder values i.e. {0}, {1} etc. in the ' message ' attribute. Reference:  https://developer.salesforce.com/docs/component-library/bundle/lightning-platform-show-toast-event/documentation

Salesforce Fact #533 | Custom finish flow behavior in LWC

Image
We can also define custom finish behavior for the flow embedded in LWC. In this example, once the screen flow finishes it is navigated to the created contact record in a new tab. Attached is the screenshot.

Salesforce Fact #532 | Access flow output variables in LWC

Image
Now we can embed lightning flow inside LWC using lightning-flow tag. We can provide input to the flow as well as we can get the output variable value. In order to get the output variables from the flow, we can make use of the outputVariables parameter of onstatuschange event.  Reference:  https://developer.salesforce.com/docs/component-library/bundle/lightning-flow/documentation Attached are the screenshots of one such example. In this case, we are returning the record Id of the created contact from screen flow to LWC.

Salesforce Fact #531 | Exempt MFA

Image
Do you know we can exempt the MFA check for some users even if it is enabled in org level. There is a system permission named 'Waive Multi-Factor Authentication for Exempt Users'.  A new permission set can be created which has this permission enabled and can be assigned to the intended users. Reference:  https://help.salesforce.com/s/articleView?id=sf.security_mfa_exclude_exempt_users.htm&type=5 Attached is the screenshot.

Salesforce Fact #530 | Grant login access to admin

Image
We know that there is a setting under 'Login Access Policies' which enables the admin users to login as other users. But do you know the users individually can grant admin login access from their settings page in case the org wide setting is not enabled. Attached is the screenshot. 

Salesforce Fact #529 | Muting permission sets

The Muting permission sets are not present in the PermissionSet object. But they can be found in the PermissionSetGroupComponent object. However, the Id of muting permission sets starts with '0QM'  while for other permission sets it starts with '0PS'.

Salesforce Fact #528 | Find out permission set assignments

Do you know there is an Sobject in Salesforce called 'PermissionSetGroupComponent' which keeps track of the permission set assignments in permission set groups. Suppose, we need to find out a particular permission set is assigned to which permission set groups. To get this, we can query on this object. For example, we can use the below query to find out the permission set 'Edit_Read_Only_Fields_Permission' is assigned to which permission set groups: SELECT Id, PermissionSetGroupId, PermissionSetGroup.MasterLabel FROM PermissionSetGroupComponent WHERE Permissionset.Name='Edit_Read_Only_Fields_Permission' For more details, check out:  https://developer.salesforce.com/docs/atlas.en-us.234.0.object_reference.meta/object_reference/sforce_api_objects_permissionsetgroupcomponent.htm

Salesforce Fact #527 | Recycle bin limit reached

Do you know what happens when the recycle bin size limit is reached in Salesforce org? Salesforce automatically removes the oldest records if they have been in the recycle bin for at least two hours. Reference:  https://help.salesforce.com/s/articleView?id=000324672&type=1

Salesforce Fact #526 | Collection read-only error

Trigger context variables are read-only. If you try to add/remove values from the collections, it will throw the below error: System.FinalException: Collection Is Read-only External Entry Point. However, clear() function can be applied on trigger.newMap and trigger.oldMap.

Salesforce Fact #525 | Setting application mode in test class

Image
Do you know there is a method called setReadOnlyApplicationMode() in Test class in apex which is used to set the application mode for only read operations to simulate the behavior during service upgrade or maintenance. We cannot perform any data updates i.e. are not allowed to perform any DML operations once this scope is enabled. Reference:  https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_test.htm#apex_System_Test_setReadOnlyApplicationMode Attached is the screenshot.      

Salesforce Fact #524 | Contact hierarchy

Similar to Account hierarchy, we have Contact hierarchy as well in Salesforce. The relationship is specified using the ReportsTo field on Contact which is a lookup to another Contact. The hierarchy can be viewed using the 'View Contact Hierarchy' button. Reference: https://help.salesforce.com/s/articleView?id=sf.contacts_hierarchy_lex.htm&type=5

Salesforce Fact #523 | Opportunity CloseDate validation

Suppose we have a use case where we need to implement a restriction that the Opportunity Close date can only be the last day of the month. We can implement the below validation rule: CloseDate <> ADDMONTHS(CloseDate, 1) - DAY(ADDMONTHS(CloseDate, 1))

Salesforce Fact #522 | Hierarchical custom settings insertion error

Have you come across this error: SetupOwnerId duplicates value on record id with id: <some record id>. This error is encountered when we are trying to insert a record in hierarchical custom settings and there is already a record present in the same level of hierarchy. For example, the below example tries to insert a org level row in the custom settings Location__c: insert new Location__c(name='test hcs'); and there is already the org level row present in the org.