Sunday, March 14, 2021

How to use getObjectInfo in Lightning Web Component?

 In this blog post we will learn how to use getObjectInfo in Lightning Web Component.

Let us take a simple example to understand the use of getObjectInfo in Lightning Web Component.



  <p>Object Info Component</p> 



import { LightningElement, wire } from 'lwc';

import { getObjectInfo } from 'lightning/uiObjectInfoApi';

import ACCOUNT_OBJECT from '@salesforce/schema/Account';

export default class ObjectInfoComp extends LightningElement {

    @wire(getObjectInfo, { objectApiName: ACCOUNT_OBJECT })

    wiredData({data, error}){


         console.log('Object INFO:', data);



         console.log('Some Error Occured');






<?xml version="1.0" encoding="UTF-8"?>

<LightningComponentBundle xmlns="">








Now, Add the component on account record lightning page as shown below,

getObjectInfo in Lightning Web Component

Open the console and we will be able to see all different information related to the object as shown below.

How to use getObjectInfo in Lightning Web Component?

No comments:

Post a Comment