Friday, June 7, 2019

lightning/uiObjectInfoApi Example (record id and object api fetching)

1. Example to fetch record Id and object API.

recordIdFetching.js-meta.xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="recordIdFetching">
    <apiVersion>45.0</apiVersion>
    <isExposed>true</isExposed>
    
    <targets>
        <target>lightning__AppPage</target>
        <target>lightning__RecordPage</target>
        <target>lightning__HomePage</target>   
    </targets>
</LightningComponentBundle>


recordIdFetching.html
<template>
    <lightning-card title="Record Id Fetching">
        <lightning-layout>
            <lightning-layout-item>
                Record Id : {recordId} <br/>
                Objcet API : {objectApiName}
            </lightning-layout-item>
        </lightning-layout>
    </lightning-card>
</template>


recordIdFetching.js

import { LightningElement, api } from 'lwc';

export default class RecordIdFetching extends LightningElement {
    @api recordId;
    @api objectApiName;
}


Finally deploy it in our auth org and keep in mind to configure this LWC component under any lighting record page.
Once done open the record where you configure the above component using lighting record page.

Output:
It will shown record id and object api name.

LWC to LWC Communication using Lightning Messaging Service (Part - 2)

In my previous post ( previous post link ) we have learn how to create a Lightning Messaging Service with 6 steps and today we will use the ...