Posts

Showing posts with the label record

Salesforce Fact #911 | Creating Location records from apex

Have you encountered this error:  DML requires SObject or SObject list type: System.Location. While creating Location records from apex, we need to specify the type as Schema.Location, else we get the above error. Sample code: Schema.Location lc = new Schema.Location(); lc.Name = 'Test location'; insert lc; Reference:  https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007X80VFSAZ

Salesforce Fact #828 | Reset value of LWC record picker using lwc:ref

Image
In LWC, if there are multiple lightning record pickers present and suppose we need to set/reset the value of a particular one, we can make use of the lwc:ref option. 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.

Salesforce Fact #795 | Readonly lightning record picker

Image
Suppose we want to make the lightning-record-picker readOnly once a value is selected. This is how we can implement this, since it does not support disabled or readOnly attributes. Attached is the screenshot.

Salesforce Fact #794 | Reset value in LWC record picker

Image
We can use the clearSelection() method to reset the value in lightning-record-picker. Reference:  https://developer.salesforce.com/docs/component-library/bundle/lightning-record-picker/specification Attached is the screenshot.

Salesforce Fact #793 | Getting selected recordId in lightning record picker

Image
So, this is how we can access the selected record Id in lightning-record-picker. Attached are the screenshots.

Salesforce Fact #791 | spanning relationship in lightning record picker

Image
Filtering in lightning-record-picker also supports spanning relationships upto one level. Reference:  https://developer.salesforce.com/docs/component-library/bundle/lightning-record-picker/documentation Attached is the screenshot.

Salesforce Fact #790 | passing value in lightning record picker filter

Image
We can pass value dynamically as well in the filter of lightning-record-picker. For example, suppose we are using a contact record picker and we would like to select only the related contacts for the current account. The LWC is placed in the account record detail page. We can pass the current accountId in the filter. Attached are the screenshots.

Salesforce Fact #785 | lightning record picker in LWC

Image
So we have a whole new tag in lwc, lightning-record-picker. This renders a record select lookup. It uses GraphQL wire adapter to fetch the records and also returns the records as per the user access i.e. in with sharing mode. Reference:  https://developer.salesforce.com/docs/component-library/bundle/lightning-record-picker/documentation Attached are the screenshots.

Salesforce Fact #764 | Associate email to Salesforce record directly

Image
Using Email to Salesforce, we can associate the email to a record directly in Salesforce. For this, we need to specify the recordId in the subject line after the text 'ref: '. Reference:  https://help.salesforce.com/s/articleView?id=sf.email_my_email_2_sfdc_using.htm&type=5 Attached are the screenshots.