Posts

Showing posts with the label getRecord

Salesforce Fact #908 | Check if current org is sandbox in LWC

Image
How to check if the current org is sandbox in LWC? One option is to call an apex method and get the data. Another option is we can use a custom field and LWC to get the data. In this approach, we create one formula field on the User object to store the current org id and then using this one, we get the IsSandbox value using getRecord on Organization object. Attached are the screenshots.

Salesforce Fact #892 | Parent record access missing in LWC getRecord

Image
While using getRecord in LWC, if the user does not have access to the parent record the parent field values are shown as null but there is no error encountered. In this example, we have an Account lookup on Lead record and fetching the Rating and Account Owner name using getRecord. Attached are the screenshots.

Salesforce Fact #884 | LWC getRecord optionalFields in action

Image
The LWC getRecord optionalFields parameter is pretty helpful to deal with fields which have been used in the getRecord but the current user does not have access to. If we specify the same field in fields parameter, the call to getRecord fails with error, while if the same field is used in optionalFields it is ignored and the data is returned for the rest of the fields. In this example, the current user does not have access to the Account Description field. Reference:  https://developer.salesforce.com/docs/platform/lwc/guide/reference-wire-adapters-record.html Attached are the screenshots.

Salesforce Fact #797 | LWC getRecord with record picker

Image
We can use LWC getRecord with lightning-record-picker to fetch the field values of the selected record. Attached are the screenshots.