Posts

Showing posts with the label getRecords

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.

Salesforce Fact #729 | LWC getRecords in screen flow

Image
Suppose we have a lookup component in the screen flow which allows selecting multiple accounts. Now, we have a requirement to get the data of the selected accounts. We can get that using an LWC which makes use of getRecords wire method to fetch the required data and display in the UI. References:  https://developer.salesforce.com/docs/platform/lwc/guide/reference-wire-adapters-records.html https://dev.to/tdrnk/lwc-getrecords-wire-adapter-how-to-retrieve-records-dynamically-apd Note: The LWC UI styling can further be improved. It is just for demonstration purpose. Attached are the screenshots.