Posts

Showing posts from March, 2023

Salesforce Fact #650 | PersonalInfo_EPIM fieldset

There is a fieldset named 'PersonalInfo_EPIM' in User object which secures personal information from guest and community users. By default, the fieldset contains 30 user fields and can be updated as well to include other fields. Reference:  https://help.salesforce.com/s/articleView?id=release-notes.rn_experiences_secure_personal_info_fields_with_field_sets.htm&release=236&type=5

Salesforce Fact #649 | LWC template refs in action

Image
With the Spring'23 release, LWC template refs are available now. In order to use this in LWC, we need to enable Lightning Web Security first using the below step: Setup -> Session Settings -> Under the section 'Lightning Web Security' select the checkbox for enabling LWS for LWC. After this, we can use lwc:ref in our code. In this example, we have a textinput and we are getting the label and value using template refs when the input is getting changed. Reference:  https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.reference_directives Attached are the screenshots.  

Salesforce Fact #648 | ApexTypeImplementor object

With the Spring'23 release, now we can get the list of all classes which implement a particular interface with the help of  ApexTypeImplementor  object. For example, if we need to find out the apex classes which implement the Database.Batchable interface we can use the below SOQL: SELECT Id, ApexClass.Name FROM ApexTypeImplementor WHERE InterfaceName = 'Batchable' For more details check out:  https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_apextypeimplementor.htm

Salesforce Fact #647 | Bulk API serial mode

We can enable serial mode processing using Bulk API in data loader. Parallel processing can cause database contention which can cause the load to fail eventually. Serial mode processes one batch at a time, but the processing time might get increased. Steps to enable Bulk API serial mode:  Open Data Loader -> Settings -> Check Bulk API -> Check Enable serial mode for Bulk API. Reference:  https://developer.salesforce.com/docs/atlas.en-us.dataLoader.meta/dataLoader/loader_configuring_bulk_api.htm

Salesforce Fact #646 | Reset draftValues in lightning datatable

Image
In datatable there is a property named 'draftValues' which keeps a track of inline edits made. Now if we have a scenario, where we need revert the inline edits made so far, we can set the draftValues to empty array using bit of logic in JS. Attached are the screenshots.

Salesforce Fact #645 | Account and oldest related contact

Suppose we need to find out account and the corresponding latest contact record. Now, we can use inner SOQL query for that. We can improve the fetch by adding a where clause so that the result is returned for the accounts which are present in contact object, skipping the accounts which does not have any related contact at all. SELECT Id, Name, (SELECT Id, Name FROM Contacts ORDER BY CreatedDate DESC LIMIT 1) FROM Account  WHERE Id IN (SELECT AccountId FROM Contact) Note: This query is only for demonstration. We should put filter the records for only the accounts which are intended for.

Salesforce Fact #644 | Access object attribute in LWC iterator

Image
How do you access object attributes in LWC iterator? So, while accessing the data from the list, it is specified as 'it.value'. In order to access the object attribute we need to go one more level, like 'it.value.<attribute_name>'. Attached are the screenshots.

Salesforce Fact #643 | Passing recordId from LWC quick action

Image
Suppose we are using an LWC as a quick action and from that component we are passing the current record Id to a child LWC for further processing. Now, an interesting thing here is  if we are calling an apex method imperatively from the child component using the same recordId passed, th en we need to check the value of it before passing, otherwise it passes undefined. Attached are the screenshots.

Salesforce Fact #642 | Record choice set limit

The maximum number of choices which can be shown for Flow Record Choice Set component is 200. So, we need to filter out records if there are more than 200 records. Reference:  https://help.salesforce.com/s/articleView?language=en_US&id=sf.flow_ref_resources_recordchoice.htm&type=5

Salesforce Fact #641 | Array of objects destructuring in LWC

Image
While working with LWC, Sometimes we need to add some additional attribute to any object structure for any interim processing and once done, they can be removed from the objects. We can use the object destructuring of JS to remove a particular attribute from an array of objects. Attached is the screenshot.

Salesforce Fact #640 | At least one line item

Image
Suppose once an opportunity is added with a related opportunity line item, it needs to have at least one line item from then on. We cannot delete all the related line items. We can implement the same using the HasOpportunityLineItem field in a validation rule. Attached is the screenshot.

Salesforce Fact #639 | Filter-based opp territory assignment

In order to use an apex class for filter-based opportunity territory assignment, the apex class needs to implement the  TerritoryMgmt.OpportunityTerritory2AssignmentFilter interface and it needs to implement the getOpportunityTerritory2Assignments() method. Reference:  https://help.salesforce.com/s/articleView?id=sf.tm2_enable_ota.htm&type=5

Salesforce Fact #638 | LWC Datatable: Edit field value for only current selected row

Image
Suppose we have a scenario where we have a single select datatable in LWC. There is a field which is editable but it should be editable only for the selected row, for rest of the rows it would be read-only. We can implement the same with a bit of logic of JS. Attached are the screenshots.

Salesforce Fact #637 | Enable task notifications

If we need to receive the notification for the created tasks, we need to make the below changes: 1) Setup -> Activity Settings -> Enable Activity Reminders. 2) Add the Reminder Set field to the Task page layout. This eventually adds the Reminder Time field to the layout. Reference:  https://help.salesforce.com/s/articleView?id=sf.tasks_enable_task_notifications.htm&type=5