0

I'd like to access the picklist values of a field on a Custom Metadata Type from an LWC:

import { getPicklistValues } from "lightning/uiObjectInfoApi";
import { getObjectInfo } from "lightning/uiObjectInfoApi";
import SYNC_MODE_FIELD from "@salesforce/schema/Setting__mdt.Sync_Mode__c";
import SETTING_MDT_OBJECT from "@salesforce/schema/Setting__mdt";

Then I am using getObjectInfo

@wire(getObjectInfo, { objectApiName: SETTING_MDT_OBJECT }) 
settingObjectInfo

And then I am using getPicklistValues

@wire(getPicklistValues, { 
                            recordTypeId: "$settingObjectInfo.data.defaultRecordTypeId", 
                            fieldApiName: SYNC_MODE_FIELD 
                          }) 
syncModes;

But both settingObjectInfo and syncModes are null

Am I correct in assuming that getObjectInfo and getPicklistValues don't support Custom Metadata Type?

2 Answers 2

1

It looks like the documentation here could use some clarification.

  1. This reference appears to leave open the possibility that Custom Metadata types may be supported by lightning/ui*Api modules (however, MDT's are not really "custom objects," strictly speaking):

https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.reference_supported_objects

The wire adapters and JavaScript functions in lightning/ui*Api modules are built on User Interface API. User Interface API supports all custom objects and many standard objects.

  1. When it comes to the Lightning Data Service overall, the documentation is clear - Custom Metadata Types are not supported:

https://developer.salesforce.com/docs/component-library/documentation/en/lwc/data_guidelines

IMPORTANT Lightning Data Service supports all custom objects and all the standard objects that User Interface API supports. External objects, person accounts, and custom metadata types are not supported.

0

First off you can import both in one line as per below. :)

import { getObjectInfo, getPicklistValues } from 'lightning/uiObjectInfoApi';

Also, as per below link it does not explicitly say it supports Custom Meta Data. User Interface API supports all custom objects and many standard objects.

https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.reference_supported_objects

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .