Created
June 14, 2022 02:36
-
-
Save banderson5144/4d5c883b41673cd38e1fd0da5053108c to your computer and use it in GitHub Desktop.
LWC getRecord Usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LightningElement, wire, api } from "lwc"; | |
//1. import the methods getRecord | |
import { getRecord } from "lightning/uiRecordApi"; | |
//2. Import reference to the object and the fields | |
import NAME_FIELD from "@salesforce/schema/Account.Name"; | |
import RATING_FIELD from "@salesforce/schema/Account.Rating"; | |
import INDUSTRY_FIELD from "@salesforce/schema/Account.Industry"; | |
const FIELDS = [NAME_FIELD, RATING_FIELD, INDUSTRY_FIELD]; | |
export default class GetRecordTestUpdate extends LightningElement | |
{ | |
@api recordId; | |
@wire(getRecord, { recordId: '$recordId', fields: FIELDS }) | |
wiredRecord({ error, data }) | |
{ | |
console.log('fooey'); | |
if(data && data.fields.Rating.value == 'Cold') | |
{ | |
console.log('The Rating is Cold'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment