Posts

Showing posts from October, 2024

Salesforce Fact #886 | Check if account description is blank using flow

Image
Long text area cannot be referenced in Salesforce formula fields. But they can be referenced in flow formula resources. Suppose, we need a flag to indicate if the description field on account is empty or not. We can create a before save record-triggered flow on Account and check if it is blank in a formula resource and store the value in a checkbox field. Attached are the screenshots.

Salesforce Fact #885 | Public group count

With SOQL query, we can get to know the count of public groups inside a Queue. We can make use of the UserOrGroupId field of GroupMember object. Example Query: SELECT Count(Id) FROM GroupMember WHERE Group.Name='Test Lead Queue' AND UserOrGroup.Name = NULL

Salesforce Fact #884 | LWC getRecord optionalFields in action

Image
The LWC getRecord optionalFields parameter is pretty helpful to deal with fields which have been used in the getRecord but the current user does not have access to. If we specify the same field in fields parameter, the call to getRecord fails with error, while if the same field is used in optionalFields it is ignored and the data is returned for the rest of the fields. In this example, the current user does not have access to the Account Description field. Reference:  https://developer.salesforce.com/docs/platform/lwc/guide/reference-wire-adapters-record.html Attached are the screenshots.

Salesforce Fact #883 | Careful while accessing getObjectInfo to get record type details

Image
We need to be careful while using getObjectInfo module to access the record types in LWC. We can access the record type name property and there is no developer name property present. The name returns the label of the record type and if translation is present for the user language then the translated value is returned. So, we need to be careful while doing any check to match the record type name. There is an Idea already submitted to add the Developername in the data returned:  https://ideas.salesforce.com/s/idea/a0B8W00000H50x7UAB/include-developername-in-the-recordtypeinfo-returned-with-getobjectinfo-in-lwc Attached are the screenshots.

Salesforce Fact #882 | Handling decimal data in LWC returned from apex wrapper

Image
We need to be careful while dealing with large decimal values in LWC returned from apex in wrapper structure. If the value is large, it is converted to String to avoid any loss of precision. Reference:  https://salesforce.stackexchange.com/questions/327214/lwc-autoconverting-decimal-into-string-sf-bug Attached are the screenshots.

Salesforce Fact #881 | Community user check using ContactId on User

Image
We can make use of ContactId field in User object to identify if the current logged in user is a community user or not. The same can be used in LWC. Attached is the screenshot. Note: The ContactId field cannot be updated manually and while trying to do so, the below error is encountered: 'You can't create a contact for this user because the org doesn't have the necessary permissions. Contact Salesforce Customer Support for help.'

Salesforce Fact 880 | Impact on query using user fullname due to user locale change

Locale changes affect the name format of the user. For some of the locales, the Lastname appears followed by Firstname when full name is displayed. So, if we have any logic where we are fetching data based on the Fullname field on User object, we need to be careful.  For example, if the user's full name is 'Tom Stewart' where Firstname is 'Tom' and Lastname is 'Stewart', in case of Hungarian(Hungary) locale this is interpreted as 'Stewart Tom'. So, either we should use any other field like username or we should use any other filter to fetch the required data.