0

Is there a way in Apex to search for picklist based on recordtype in apex without using any external library?

I know that we can capture the list of picklists from a wired function in lwc but that is hardwired to a specific object( I need that to be dynamic).

I know that it's possible to get it through VF page but that is a old way of getting the result.

I see that it's possible to do with the Metadata class but not sure how to get the data.

1 Answer 1

1

getPicklistValues is not necessarily hardwired, you can use it as follows:

    @track recordTypeId;
    @track picklistFieldName;

    @wire(getPicklistValues, { recordTypeId: "$recordTypeId", fieldApiName: "$picklistFieldName" })
    propertyOrFunction;


    somefunction(){
        ...
        this.recordTypeId = someRecordTypeId;
        this.picklistFieldName = "SomeObject.SomeField__c";
    }

You can find an objects default recordtype id or it's recordtypes by using getObjectInfo which can dynamically get any object in the same way.

0

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.