Posts

Showing posts from December, 2021

Salesforce Fact #279 | Simple Web to Case form using screen flow

Image
Suppose we would like to create a simple Web to Case form. We can create a screen flow to achieve this. The user would also be able to upload any supporting document and the document would be saved as a related attachment of the case. Attached are the screenshots.  

Salesforce Fact #278 | Access custom geolocation fields in LWC

Image
If we want to access custom geolocation fields in LWC using getRecord, then we have to refer the field Apinames statically. Importing from '@salesforce/schema' won't work. Attached are the screenshots.

Salesforce Fact #277 | Field spanning limit in LWC

Image
Do you know there is a limit of spanning on accessing the relationship field in LWC. We can refer relationship field upto 5 levels. Attached is the screenshot. For more details check: https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.apex_schema  

Salesforce Fact #276 | Access geolocation field values in LWC

Image
We can access Geolocation field values in LWC using getRecord. In this example, we are accessing Shipping Geolocation values of account record in LWC. Attached are the screenshots.

Salesforce Fact #275 | Import field with namespace in LWC

Image
Suppose we have to import multiple fields in LWC of a standard object. Now some of the fields are standard and some are custom fields. The custom fields have a namespace at the start. So, if we try to import them from '@salesforce/schema' it will throw error. As a workaround, we can refer the custom field Apinames statically and get their value from getRecord. In this example, we have a custom field AutoNum__c on Account which is having a namespace. So, we have referred the field statically before retrieving its value. Attached are the screenshots.

Salesforce Fact #274 | Skip null check in screen flow

Image
Suppose we have two input text fields in the screen flow and at a time only one input can be provided. Now after the user enters the data, we generally check from which text field the data came. But if we use a text variable and simply append the value of the two input fields, we can skip this decision element use to check the condition. Since, we would be appending the data so for the hidden field it will simply add NULL and would not make any change to the actual result. Attached are the screenshots.

Salesforce Fact #273 | Get case assignment rule details from debug log

Image
We can check the details of Case assignment rule from the debug log. It starts with a scope of WF_CRITERIA_BEGIN. It displays the Case recordId, Casenumber, Assignment rule Id and name. And it also displays WF_CRITERIA_END|true for the matched condition. Attached are the screenshots.

Salesforce Fact #272 | Get address field values using getRecord

Image
We can get Address field values using getRecord in LWC. In this example, we are getting Shipping Address details for account using getRecord. Attached are the screenshots.

Salesforce Fact #271 | Span field across 2 column in same section

Image
Suppose we would like to span a particular field across two columns on one section of the page layout. But we would like to keep the other fields as it is. Now the column span is decided from the section setting on page layout. So, in this scenario we can create one new section and would hide the header of the section and also enable the layout as 1-column. Now, it will appear as if the field which is spanning across 2 columns is within the same section of the other fields but actually it is inside a different section. In this example, we would like to show the Account Source field spanned across two columns and below the Billing Address field in the Address Information section. Attached are the screenshots.

Salesforce Fact #270 | Lookup filter in screen flow

Image
Suppose we have a use case where we need to show only specific records in a lookup input field in screen flow. Now, the thing is the lookup field in the screen flow basically refer to an existing lookup field in the org, it is not a whole new field inside the flow. We need to specify the api name of the field as well as of the object. Now, let's say we want to have a account lookup input in the screen flow which will show records only of a particular record for selection. For this, we need to create a lookup filter in that same field in the org. In this example, we want to show account records which are having record type as 'Test RT1'. So we create a lookup filter on the Account lookup field on Contact. Attached are the screenshots.

Salesforce Fact #269 | Select exactly one lookup using screen flow

Image
Suppose we have a use case where we need to select exactly one lookup: either account or contact in a screen flow. We can make use of component visibility option to hide one lookup when the other is selected. Also we can use required input attribute to ensure user needs to select one lookup. Attached are the screenshots.

Salesforce Fact #268 | Iterate over string in apex

Image
Apex does not support char data type. So, suppose we have to iterate over the characters over a string. We can use substring() method to get the characters at each index. Attached are the screenshots.

Salesforce Fact #267 | Reusable LWC to get RecordTypeId of current record

Image
We can have a reusable LWC component which can be used across all the object record pages which have record type available. Suppose, we need to get the recordTypeId of the current record and that is a common requirement for multiple Sobject record pages. In that case, we can have a generic LWC component which accepts the current record Id and current SObject type as input and passes the same to apex controller and returns the record type Id for the current record. Attached are the screenshots.