Posts

Showing posts from November, 2024

Salesforce Fact #893 | OLI insert/update triggers Opp triggers and flows

When an Opportunity Product record is created or during update if certain fields like Sales price/Quantity is updated, it executes the before and after update triggers and flows on related opportunity. So, we need to be careful while creating any automation on Opportunity Product. Reference:  https://salesforce.stackexchange.com/questions/184659/opportunitylineitem-fires-opportunity-trigger

Salesforce Fact #892 | Parent record access missing in LWC getRecord

Image
While using getRecord in LWC, if the user does not have access to the parent record the parent field values are shown as null but there is no error encountered. In this example, we have an Account lookup on Lead record and fetching the Rating and Account Owner name using getRecord. Attached are the screenshots.

Salesforce Fact #891 | Accessing custom metadata in screen flow formula

We can use Custom Metadata in flow entry criteria formula and also in formula resource. Here is the syntax:  {!$CustomMetadata.<Metadata api name>.<Record Name>.<Field api Name>} example: {!$CustomMetadata.Country__mdt.Brazil.Region__c}

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.