Posts

Showing posts from September, 2022

Salesforce Fact #521 | ConvertLeads access check in LWC

How can we check ConvertLeads permission in LWC. This is how we can import the permission and check: import hasConvertLeadAccess from '@salesforce/userPermission/ConvertLeads';

Salesforce Fact #520 | GroupMember scenarios

Image
The GroupMember object keeps track of all queue and public group assignments. Let's see the scenarios: 1) When a user is added to a public group, a row gets created where the Group Id is the Public group Id and UserOrGroupId is the user Id. The Group type is Regular. 2) When a user is added to a queue, a row gets created where the Group Id is the queue Id and UserOrGroupId is the user Id. The Group type is Queue. 3)  When a public group is added to a queue, a row gets created where the Group Id is the queue Id and UserOrGroupId is the public group Id. The Group type is Queue. Attached is the screenshot.

Salesforce Fact #519 | Listview metadata in VS Code

Image
So, we have 3 types of sharing settings in list view: 1) Only I can see this list view. 2) All users can see this list view. 3) Share list view with groups of users. Now, let's see how they are represented in metadata  xml   format. For the 1st option, we cannot retrieve the metadata since this is private to that specific user and attempting to retrieve generates error: For the 2nd option, the sharing scope is denoted by the filterScope tag: For the 3rd option, the sharing for each public group is denoted by sharedTo tag:

Salesforce Fact #518 | View all & Modify all data check in LWC

Image
Do you know using the @salesforce/userPermission module, we can check the ViewAllData and ModifyAllData access for the current user in LWC. Attached are the screenshots.  

Salesforce Fact #517 | Status field on Entitlement object

Do you know the Status field on Entitlement object is not a writeable field. It can have the below statuses: Active if the system date is equal to or later than the Start Date and equal to or earlier than the End Date. Expired if the system date is later than the End Date. Inactive if the system date is earlier than the Start Date . Reference:  https://help.salesforce.com/s/articleView?id=sf.entitlements_fields.htm&type=5  

Salesforce Fact #516 | Delete all white spaces in apex string

Image
In Apex, we have the trim() function to remove the leading and trailing spaces from the string. But what if we want to remove all the white spaces from the string. There is a method deleteWhitespace(). Reference:  https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_System_String_deleteWhitespace Attached are the screenshots.

Salesforce Fact #515 | Get Community context for LWC

Image
Suppose we need to check whether the current context of the LWC is in community or internal page. We can use a checkbox and set it to true while adding the LWC in community page and for internal, keep it as false. Attached is the screenshot.

Salesforce Fact #514 | Previous record type check in validation rule

Image
Suppose we have a use case where we need to check previous record type name in order to put some validation when the record type is changed on the record. Now, the limitation is PRIORVALUE() cannot take RecordType.Name or RecordType.DeveloperName as parameter. So, to resolve this we can create a formula field of text type which will hold the value of RecordType.DeveloperName and we can use this field along with PRIORVALUE() in our validation rule. In this example, there are two record types: Test_RT1 and Test_RT2 in Account and we want to restrict the record type change from Test_RT1 to Test_RT2. Attached are the screenshots.

Salesforce Fact #513 | LastViewedDate & LastReferencedDate

Do you know, in order to access the LastViewedDate and LastReferencedDate fields in SOQL the object needs to have tab created, otherwise those are not accessible.

Salesforce Fact #512 | Standard Address object

Do you know, there is a standard Address object in Salesforce which is available once Field Service Lightning is enabled in the org. Reference: https://help.salesforce.com/s/articleView?id=sf.fs_standard_objects.htm&type=5

Salesforce Fact #511 | Global cache for apex methods

Do you know, In API version 55.0 and later, you can use the annotation @AuraEnabled(scope='global') along with @AuraEnabled(cacheable=true) to enable Apex methods to be cached in a global cache. Reference:  https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_AuraEnabled.htm

Salesforce Fact #510 | Enable MFA for all users in the org

Image
So how can we enable MFA for all users in the org. We need to enable the setting 'Require multi-factor authentication for all direct UI logins to your Salesforce org' in Identity Verification section from setup. Reference:  https://trailhead.salesforce.com/content/learn/projects/quick-start-turn-on-multi-factor-authentication/enable-mfa-for-everyone-in-your-org Attached is the screenshot.

Salesforce Fact #509 | Custom validation message in screen flow using LWC

Image
Suppose we need to show custom toast error message in screen flow using LWC. We have two input fields: FirstName and LastName. If any of the input is not filled, the user cannot move to the next screen and gets to see a toast error message. Attached are the screenshots.

Salesforce Fact #508 | Ends with in validation rule

Image
We have BEGINS() function in validation rule to check whether a String starts with a particular text. But there is no function to check whether a String ends with a particular text. We can implement the same using a bit of tweak in the logic. Suppose, we have a use case where the Account description does not end with the word 'Test'. We can use the RIGHT() function to implement this logic. Also to make the text configurable, we can use custom labels and also in order to check case insensitivity we can use UPPER/LOWER functions. Attached are the screenshots.

Salesforce Fact #507 | Session-based permission set in action

Image
Do you know there is an option in flow to Activate and Deactivate session based permission set. This is helpful while granting extended access to the user only during the session. Suppose, we have a screen flow where it fetches some of the highly restricted account records which are managed by only key members in the org and should not be updated by others. So we can create a session based permission set and assign this to the intended users who would be accessing the flow. This permission set would grant them view all account access only during the session. Attached are the screenshots.

Salesforce Fact #506 | Session based permission set error

Have you encountered this error: 'The permission set must be pre-assigned to the user before being activated'. This error comes up when we try to activate a session based permission set, but the user in the current context is not pre-assigned the permission set yet.

Salesforce Fact #505 | Apply Lead Assignment Rule flow action

Image
Do you know there is a flow action called 'Apply Lead Assignment Rules' under Sales leads category. It ensures the assignment rules are run on the specified lead record Id. Suppose we have a scenario where we have a lead form in screen flow and we want the lead assignment rule to be fired during the lead creation. We can make use of this action. Attached are the screenshots.

Salesforce Fact #504 | Handover open tasks to related account

Image
Suppose we have a use case where we need to handover open tasks to the related account record when the opportunity gets deleted. We can implement the same using record-triggered flow. Attached are the screenshots.  

Salesforce Fact #503 | Chatter post visibility from flow

Image
So we have two possible values to select for the visibility in chatter post, allUsers & internalUsers. Let's see how it works from post to chatter action in flow. Attached are the screenshots.

Salesforce Fact #502 | addError() on audit fields

Image
Applying addError() method on audit fields does not cause any impact. Although these fields are not visible in the edit detail page, the error message still appears similar to other addError messages. Attached are the screenshots. Note: The code snippet has no business logic, it is only for demonstration purpose.

Salesforce Fact #501 | Implications of deleting predefined case team

In order to delete a predefined case team, its reference needs to be removed first from the assignment rule. Also, once the team is deleted it gets deleted from all existing case records where it was added. Same goes for the individual predefined case team members. Reference:  https://help.salesforce.com/s/articleView?id=sf.caseteam_predefine_team.htm&type=5