Posts

Salesforce Fact #890 | Unassign a PS from all PSGs

Image
Suppose we have a PS which is assigned to multiple PSGs. Now, for some reason we would like to unassign it from all the PSGs. The attached apex code snippet would be helpful for the same:

Salesforce Fact #889 | Validation on address input parts in screen flow

Image
We can set the Required option to TRUE for the Address type input in screen flow. But that would make all the address components to be required. Suppose, we want to keep a validation such that when the state is selected the user should also provide the city in the input. For this, we can make use of the validate input option. Attached are the screenshots.

Salesforce Fact #888 | Handle error in common getRecords LWC

Image
Suppose you have an LWC which has a getRecord and is getting used across multiple object record pages. Now, if the fieldList is not consistent with the recordId then error is encountered. So, in order to handle this, we can check the sobjecttype and for the respective sobject we can return respective fields and if there is no logic built yet for any sobject, we can just pass the Id or empty array in the fields property to avoid the error. Attached is the screenshot.

Salesforce Fact #887 | fields empty on LWC getRecords

Image
If the fields parameter in LWC getRecords is an empty array, then it returns no data neither it returns any error. It just skips the execution of the getRecords. Note: This is just a POC and ideally the fields array won't be empty. Attached are the screenshots.

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