I am trying to use the 'getPicklistValues' in a lightning web component.

The goal is to get the picklist values of a custom field on 'User'. However to use the wire function you have to pass a recordTypeId, this doesn't seem possible, since Users don't have record types assigned to them. I am able to do this custom, but I was wondering if there's an option to do this with the default 'getPicklistValues' function.

Sample code for reference;

import { LightningElement, wire, api } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
import { getPicklistValues } from 'lightning/uiObjectInfoApi';
import { getObjectInfo } from 'lightning/uiObjectInfoApi';

import USER_OBJECT from '@salesforce/schema/User';
import CUSTOM_FIELD from '@salesforce/schema/User.Custom_field__c';
import userId from '@salesforce/user/Id';

export default class UserCustomFieldSelect extends LightningElement {
@api uId = userId;

@wire(getObjectInfo, { objectApiName: USER_OBJECT})

@wire(getPicklistValues, { recordTypeId: '$objectInfo.data.defaultRecordTypeId', fieldApiName: ACTIVE_OFFICE_FIELD})

@wire(getRecord, { recordId: '$uId', fields: [CUSTOM_FIELD]})

You have missed one thing in your code syntax. i.e '$objectInfo.defaultRecordTypeId' will not give the default value but '$objectInfo.data.defaultRecordTypeId' will. You missed using data to get the defaultRecordTypeId.

A sample example to use the default record type for getting picklist value in Lightning web component.

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

@track objectInfo;

@wire(getObjectInfo, { objectApiName: CONTACT_OBJECT })

@wire(getPicklistValues, {
   recordTypeId: '$objectInfo.data.defaultRecordTypeId',
   fieldApiName: GENDER_FIELD


On User object, we don't have any master record type. I have confirmed it through below piece of code:-

Schema.DescribeSObjectResult dsr = User.SObjectType.getDescribe();
Schema.RecordTypeInfo defaultRecordType;
for(Schema.RecordTypeInfo rti : dsr.getRecordTypeInfos()) {
    if(rti.isDefaultRecordTypeMapping()) {
        defaultRecordType = rti;

This is the reason, you are getting the defaultRecordTypeId as undefined.

  • This was indeed missing, however defaultRecordTypeId for the user object still returns 'undefined' – Kobe Oct 4 '19 at 9:40
  • 1
    @Kobe Please see the update. – sanket kumar Oct 4 '19 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.