function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SF Beginner 2019SF Beginner 2019 

Dynamic Picklist in Lightning

How can I store this on a picklist.

is my attribute correct?
<aura:attribute name="Type" type="String" />

this is my apex class to return list
@AuraEnabled
    
    public static List<String> getAuthorized(string recordId){
        List<ID> coid = new List<ID>();
        
        List<String> MemName = new List<String>();
        for( Member__c covmem :  [SELECT Id,Name, FROM Member__c WHERE Account__c =: recordId ] )
        {
            coid.add(covmem.Personel__c);  
        }
        for(Personel__c cov : [SELECT Id,Name FROM Personel__c WHERE Id =: coid ]){
            
            MemName.add(cov.Name);
        }
        return MemName;
    }

this is my helper
getAuthorized : function(component,event,helper){
        var recordId = component.get("v.recordId");
        var action = component.get("c.getAuthorized");
        action.setParams({recordId : recordId});
        action.setCallback(this,function(response){
            var state = response.getState();
            if(state === "SUCCESS"){
               //alert(JSON.stringify(response.getReturnValue()));
                 var coidpicklist = response.getReturnValue();
 				component.set("v.Type",coidpicklist);
                //var coidpicklist = response.getReturnValue()[0].ValuePicklist__c;
            }
        });
        $A.enqueueAction(action);
    },


 
VinayVinay (Salesforce Developers) 
Hi,

Review below working example to get picklist values

https://www.biswajeetsamal.com/blog/get-picklist-values-dynamically-in-lightning-component/

Thanks,
Vinay Kumar
Maharajan CMaharajan C
You can use any one of the below ones:

<aura:attribute name="Type" type="String[]" />

or

<aura:attribute name="Type" type="List" />

Check the below link for attribute data types reference:
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_attr_types_collection.htm

Thanks,
Maharajan.C