Skip to main content
Hi All,

I have a requirement where I need to display a set of picklist values that are dynamically fetched for each account. 

I am able to display picklist values, but each account has the union of all the picklist values of all the accounts in the drop down.

Eg:

If we assume 5 accounts displayed on the lightning data table and each account has 3 picklist values, with the current code, I have 15 picklist values displayed for all the accounts.

I don't need the answer to be spoon-fed to me but a basic idea of how to do would be enough.

TIA
답변 1개
  1. 2021년 5월 17일 오전 10:27
    Hi Vamsi Krishna

    Greetings!

    In Lightning component create a list attribute.

    Now, In apex, we return a list of String which has all the values of picklist-

    class PicklistValue {

        @AuraEnabled

        public static List<String> fetchPicklistValue() {

            Set<String> values = new Set<String>();

            for(Account acc : [SELECT valueField__c FROM Account WHERE valueField__c != NULL]) {

                values.add(acc.valueField__c);

            }

        }

        return(new List<String>{values});

    }

    If you find your Solution then mark this as the best answer. 

    Thank you!

    Regards,

    Suraj Tripathi
0/9000