Develop Secure Code
ui*Api Supported Objects
getObjectInfo
getObjectInfos
getPicklistValues
getPicklistValuesByRecordType
getObjectInfoUse this wire adapter to get metadata about a specific object. The response includes metadata describing the object’s fields, child relationships, record type, and theme.
1import { LightningElement, wire } from "lwc";
2import { getObjectInfo } from "lightning/uiObjectInfoApi";
3import ACCOUNT_OBJECT from "@salesforce/schema/Account";
4
5export default class Example extends LightningElement {
6 @wire(getObjectInfo, { objectApiName: ACCOUNT_OBJECT })
7 propertyOrFunction;
8}1GET /ui-api/object-info/{objectApiName}getObjectInfo uses this User Interface API resource.
| Parameter Name | Type | Description | Required? |
|---|---|---|---|
objectApiName | String | The API name of a supported object. | ![]() |
Read the data that’s returned by the wire adapter using a property or function.
propertyOrFunction—A private property or function that receives the stream of data from the wire service.
@wire, the results are returned to the property’s data property or error property.@wire, the results are returned in an object with a data property and an error property.data—Object Infoerror—FetchResponseTo get metadata for a single object, use getObjectInfo. To work with multiple objects, use getObjectInfos.
This example returns the record type Ids and the Id that matches the record type name “Special Account”.
1import { LightningElement, api, wire, track } from "lwc";
2import { getObjectInfo } from "lightning/uiObjectInfoApi";
3import ACCOUNT_OBJECT from "@salesforce/schema/Account";
4
5export default class RecordFormWithRecordType extends LightningElement {
6 // Flexipage provides recordId and objectApiName
7 @api recordId;
8 @api objectApiName;
9
10 @track objectInfo;
11
12 @wire(getObjectInfo, { objectApiName: ACCOUNT_OBJECT })
13 objectInfo;
14
15 get recordTypeId() {
16 // Returns a map of record type Ids
17 const rtis = this.objectInfo.data.recordTypeInfos;
18 return Object.keys(rtis).find((rti) => rtis[rti].name === "Special Account");
19 }
20}See Compare Base Components for a full example.
See Also