Example 1
getObjectInfoadapter js
import { LightningElement,track } from 'lwc';
import {getObjectInfoApi} from 'lightning/uiObjectInfoApi';
import Contact_OBJECT from '@salesforce/schema/Contact';
export default class AccountDisplatRecords extends LightningElement {
defaultRecordTypeId
@wire(getObjectInfoApi, {objectApiName:Contact_OBJECT})
objectInfo({data,error}){
if(data){
// check Inspect all the atribute we get it
this.defaultRecordTypeId = data.defaultRecordTypeId
}if(error){
console.error(error)
}
}
}
getObjectInfoadapter html
<tempalte>
<lightning-card title = "getObjectInfo Adapter">
<div class="slds-var-p-around_medium">
{defaultRecordTypeId}
</div>
</lightning-card>
</tempalte>
Another Example 2
getObjectInfoadapter js
import { LightningElement,track } from 'lwc';
import {getObjectInfoApi} from 'lightning/uiObjectInfoApi';
import Contact_OBJECT from '@salesforce/schema/Contact';
export default class AccountDisplatRecords extends LightningElement {
defaultRecordTypeId
@wire(getObjectInfoApi, {objectApiName:Contact_OBJECT})
objectInfo
}
getObjectInfoadapter html
<tempalte>
<lightning-card title = "getObjectInfo Adapter">
<div class="slds-var-p-around_medium">
defaultRecordTypeId: {objectInfo.data.defaultRecordTypeId}
defaultapiName: {objectInfo.data.apiName}
</div>
</lightning-card>
</tempalte>
getObjectInfos
Use this wire adapter to get metadata for multiple objects. The response includes metadata describing
the fields, child relationships, record type, and theme for each objects
Syntax
import {LightningElement, wire} from 'lwc';
import {getObjectInfos} from 'lightning/uiObjectInfoApi';
import CONTACT_OBJECT from '@salesforce/schema/Contact';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
export default class GetObjectInfosExample extends LightningElement{
objectapirecords = [ACCOUNT_OBJECT,CONTACT_OBJECT];
@wire(getObjectInfos,{objectApiNames : $objectapirecords})
propertyorFunction
}
No comments:
Post a Comment