Posts

Showing posts from January, 2022

Salesforce Fact #308 | Check ownerid in formula editor

Image
Do you know we have two additional Owner fields available on formula editor for objects like Case or Lead where the Owner can be user or queue. Suppose, we have a use case where we need to check whether the record owner is a queue or user. One option would be to use this Owner(Queue) field and check its Id. Another option would be to check if the record owner id begins with '00G' as for queue the record Id starts with '00G'. Attached are the screenshots.

Salesforce Fact #307 | Pass date value from flow to LWC

Image
Do you know we have a targetConfig property type Date in LWC. But this is applicable only for lightning flowscreen. So we can pass input date value from screen flow to LWC. For more details, please check:  https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.reference_configuration_tags Attached are the screenshots.

Salesforce Fact #306 | Get latest lead Owner Id from flow

Image
We can define assignment rules on Lead & Case objects. Now, suppose we have a use case where we have active assignment rule and we would like to access the latest Owner Id of the record in trigger/flow after the assignment rule is run while the record is created. Now, as per the Order of Execution all the before and after triggers are run before the assignment rule. But after save record triggered flow could be helpful in this case to get the updated data since they are run after the assignment rule. In this example, we have active assignment rule on Lead. To demonstrate the scenario, we are creating one Account each from the after insert Lead trigger and after insert Lead record trigger flow and storing the Lead Owner Id in the account description. The trigger is getting the Owner Id before the assignment rule is run, but the flow is able to get the Owner Id of the queue. Attached are the screenshots.

Salesforce Fact #305 | String.valueOf() fails silently on NULL value

Image
It is always good practice to check whether the value is NULL before applying any function on it. However, just in case we missed to check that and if the value is NULL and if we are using String.valueOf() function, then it will fail silently and would impact the subsequent processing. So we need to be extra careful while working with String.valueOf(). Attached is the screenshot.

Salesforce Fact #304 | Record trigger flow and triggers: Order of Execution

Image
According to Order of Execution, the before save record triggered flows are executed, then the before triggers and after triggers and finally the after save record triggered flow are executed. This is a small demonstration for the same.    

Salesforce Fact #303 | Instant page message in VF page

Image
Suppose we have an input field in VF page and we would like to show instant error message when the input is blank. When it is not blank, the error message should disappear and it will appear again once it is blank. We can get this by using reRender option and Apex PageMessages. In this example, the reRender is taking place when the input is focus out. Attached are the screenshots.

Salesforce Fact #302 | Get date value from current record in LWC

Image
Suppose we have a use case where we need to get the date value from the CreatedDate of the current record in LWC in YYYY-MM-DD format. With a little tweak of JS date functions, we can get the result. Attached is the screenshot.

Salesforce Fact #301 | OwnerId in before Insert triggers

Image
Unlike audit fields, we can get the value of OwnerId in before Insert triggers. Attached are the screenshots.

Salesforce Fact #300 | Dynamic datasource in LWC targetConfig property

Image
We can show picklist options in LWC using dynamic datasource value in targetConfig property. For this, we need to create an apex class and populate the dynamic values. In this example, we are populating the picklist options from a custom settings. For more details, please check  https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_config_for_app_builder_dynamic_picklists.htm Attached are the screenshots.  

Salesforce Fact #299 | Access current record and parent record values in LWC screen action

Image
We all know that LWC can now be used as a headless or screen quick action. Now suppose we have a use case where we need to access current record field values as well as the related record field values in a LWC screen quick action.  We can achieve this using an @api variable named 'recordId' & simply using LDS. Attached are the screenshots.

Salesforce Fact #298 | Reusable LWC to show help text in screen flow

Image
In screen flow, we have help text option for many input types. But for certain input types like email, phone, toggle, URL there is no help text option. So if we have a use case where we need to show help text for these type of inputs, we can create a reusable LWC component to show the help text for each of the input types. Attached are the screenshots.