Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

getrecord lwc

import { LightningElement, wire } from 'lwc';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import NAME_FIELD from '@salesforce/schema/Account.Name';
import OWNER_NAME_FIELD from '@salesforce/schema/Account.Owner.Name';
import PHONE_FIELD from '@salesforce/schema/Account.Phone';
import INDUSTRY_FIELD from '@salesforce/schema/Account.Industry';

export default class Example extends LightningElement {
    @wire(getRecord, { recordId: '001456789012345678', fields: [NAME_FIELD, INDUSTRY_FIELD], optionalFields: [PHONE_FIELD, OWNER_NAME_FIELD] })
    account;

     get name() {
        return getFieldValue(this.account.data, NAME_FIELD);
    }

    get phone() {
        return getFieldValue(this.account.data, PHONE_FIELD);
    }

    get industry(){
        return getFieldValue(this.account.data, INDUSTRY_FIELD);
    }
    
    get owner() {
        return getFieldValue(this.account.data, OWNER_NAME_FIELD);
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: grid in chart.js 
Javascript :: .includes is not a function 
Javascript :: monaco editor get content 
Javascript :: json stringify number 
Javascript :: remove an last item of array in javascript 
Javascript :: context api 
Javascript :: reactjs alert 
Javascript :: how to avoid duplicate values in dropdownlist using jquery 
Javascript :: vue date filter component 
Javascript :: jQuery intellisence in VSCode 
Javascript :: js byte size 
Javascript :: how to receive window.postmessage event in angular 9 
Javascript :: react change background image on hover 
Javascript :: return inside ternary operator javascript 
Javascript :: javascript color green to red 
Javascript :: updating json object in mysql database 
Javascript :: last element of array 
Javascript :: 1 day ago javascript 
Javascript :: javascript array some 
Javascript :: jquery modal show 
Javascript :: experss cookie session 
Javascript :: jquery ajax refresh 
Javascript :: recursion mdn 
Javascript :: react chartjs 2 
Javascript :: setCenter: not a LatLng or LatLngLiteral with finite coordinates: in property lat: not a number 
Javascript :: Update matched key values in two JavaScript objects 
Javascript :: jest cannot find module 
Javascript :: javascript cookies vs session vs local storage 
Javascript :: passing multiple props to child component in react 
Javascript :: react file preview 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =