0

I have the following LWC but cannot seem to get the Picklist values

Javascript

import { LightningElement,track, wire, api } from 'lwc';
import { getPicklistValues } from 'lightning/uiObjectInfoApi';
import TeamMemberRole from '@salesforce/schema/OpportunityTeamMember.TeamMemberRole';
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
import OPPORTUNITYTEAMMEMBER_OBJECT from '@salesforce/schema/OpportunityTeamMember';


         @wire(getObjectInfo, { objectApiName: OPPORTUNITYTEAMMEMBER_OBJECT })
    opportunityteammemberInfo;

    @wire(getPicklistValues,
        {
            recordTypeId: '$opportunityteammemberInfo.data.defaultRecordTypeId',
            fieldApiName: TeamMemberRole
        }
    )
    TeamMemberRoleValues;

Template

 <lightning-combobox name="progress" label="TeamMemberRole" value={value} options={TeamMemberRoleValues.data.values}
                                                    onchange={setTeamMemberRole}>
                                                </lightning-combobox>

What am I missing. I also tried without recordTypeId but this also does not work. I do not have any error. Thanks in advance.

2 Answers 2

2

There is no Record Type on OpportunityTeamMember and in getPicklistValues recordTypeId is required.

you can use apex script :

Schema.DescribeFieldResult pickList = {Object_Api_Name}.{Picklist_Api_Name}.getDescribe();
for( Schema.PicklistEntry pickVal : pickList.getPicklistValues()){
    System.debug(pickVal.getLabel()+' '+ pickVal.getValue());
}
0

Since OpportunityTeamMember is related to opportunity and OpportunityTeamMember does not have a record type we can get the default record type from opportunity in my case the following worked without having to resolve this with apex.

 @wire(getObjectInfo, { objectApiName: OPPORTUNITY_OBJECT })
    opportunityInfo;

    @wire(getPicklistValues,
        {
            recordTypeId: '$opportunityInfo.data.defaultRecordTypeId',
            fieldApiName: TeamMemberRole
        }
    )
    TeamMemberRoleValues;

You must log in to answer this question.

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