2

Felt like picklists and record types have always been a hassle, not sure if anything has changed recently.

So I am trying to build a 'create new Case' lightning component that is to mimic the VF page and the issue right now is filter the picklist values for a field I got from Schema.getglobaldescribe() based off of record type.

From what I can tell, metadata api is still the only option for this, and there isn't a good path for this through apex, which is an issue because metadata api requires certain permissions?

Anyone find a good solution for this situation?

1

You might try the lightning api here.

Specifically

1
  • 2
    both links are dead
    – Nick Kahn
    Sep 2 '17 at 20:46
1

There's now a good solution: Use Lightning Web Components and the getPicklistValuesByRecordType wire adaptor.

In the spirit of StackExchange, here's the key code:

import { getPicklistValuesByRecordType } from 'lightning/uiObjectInfoApi';
export default class PicklistValuesByRecordType extends LightningElement {


@track value;
@track options;

@wire(getPicklistValuesByRecordType, { objectApiName: 'Account', recordTypeId: '012B0000000gTUOIA2' }) 
IndustryPicklistValues({error, data}) {
    if(data) {
        this.options = data.picklistFieldValues.Industry.values;
    }
    else if(error) {
        window.console.log('error =====> '+JSON.stringify(error));
    }
}

handleChange(event) {
    this.value = event.target.value;
    }
}

However, credit for this goes to Shaik Nagajani. He has more information here.

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.