Posts

Showing posts from March, 2024

Salesforce Fact #825 | Custom property editor in screen flow

The custom property editor is a useful feature in screen flow. It can work as a container of several base components and can pass the data to the screen as set by admin. Flow builder has a JavaScript class for this purpose that uses the inputVariables and validate interfaces. In order to pass the data, the event propagation attributes need to be specified and the custom event name must be 'configuration_editor_input_value_changed'. Reference:  https://developer.salesforce.com/docs/platform/lwc/guide/use-flow-custom-property-editor-lwc-example.html

Salesforce Fact #824 | Simplifed check in validation rule

Suppose we have a use case in validation rule, where we need to restrict the change of some fields for all persona and if the user has a particular custom permission set assignment then the validation stays the same except for one field. So, instead of repeating the condition check we can simplify the condition since few of the fields are anyways common: OR( ISCHANGED(AccountNumber), ISCHANGED(AnnualRevenue), IF(NOT $Permission.Test_Custom_Perm, ISCHANGED(NumberOfEmployees), FALSE) ) In the above example, the user is restricted to update Account number, Annual Revenue and Numberofemployees fields with the exception for  NumberOfEmployees if the user is assigned the  Test_Custom_Perm custom permission.

Salesforce Fact #823 | Count restriction with repeater and datatable combo in screen flow

Image
With the new Repeater(Beta) component in screen flow, we can repeat the same input structure multiple times as we want but there is no simple way of putting a validation on the count i.e. till how many instances the repeat should happen. We can use a datatable to show the data entered in the repeater instances and at the same time make use of the minimum selection and maximum selection options to restrict the number of user selections. In this example, we are using the Repeater component to accept input for the account record fields and in the data table the entered data is shown and the user is allowed to select maximum 3 records, thus imposing the restriction on the count. Attached are the screenshots.

Salesforce Fact #822 | Validation on case closure

Image
Suppose we want to add a validation that a case can only be closed if the current user is the owner or he is part of the owner queue. We can check the current user id against the owner id or if there is a row present in GroupMember object for this user. The validation be implemented in record-triggered flow using the custom error component. Attached are the screenshots.

Salesforce Fact #821 | Accounts and related notes

Suppose we need to find out the related notes for the account records. We can use the below query: SELECT Id, Name, (SELECT Id, ContentDocumentId FROM ContentDocumentLinks WHERE ContentDocument.FileType='SNOTE') FROM Account Note: Note records are stored with filetype as 'SNOTE'

Salesforce Fact #820 | Auto populate date in repeater component in screen flow

Image
Suppose we have a use case in screen flow where we need to autopopulate some date input based on the user choice in all the instances of the repeater component. So, we can have a checkbox 'apply to all' along with a date type input. Once the checkbox is selected, the input date will get populated automatically in repeater instances. Thanks to the screen reactivity support of Repeater(Beta) which avoids manually changing the date in each of the repeater instances. Attached are the screenshots.

Salesforce Fact #819 | Checking duplicates in array in LWC

Many times  in LWC or JS,  we need to check if an array of primitive types contains a duplicate or not. The indexOf() method can be used to identify the same. Example: const arr = ['a', 'b', 'c', 'a']; const result = arr.filter((row, index)=>arr.indexOf(row)!=index) if(result.length > 0){     console.log('array contains duplicate'); } else{     console.log('array does not contain duplicate'); } Reference:  https://flexiple.com/javascript/find-duplicates-javascript-array

Salesforce Fact #818 | Simplified exists check in Map with null coalesecing

Image
Suppose, we want to check if a key does not exist in map or if the corresponding value is null, then it needs to be updated with the new value.  With the new null coalescing operator, the exists check in map can be simplified. Attached is the screenshot.