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
azhar khasimazhar khasim 

passing list of users into a picklist and display in Lightning Component

The Picklist field is visible but users are not visible and I am not able to select the users.

Apex Class: 
 
public static List<String> getPickListValuesIntoList(){
        List<String> pickListValuesList = new List<String>();
        List<User> us = [Select id, name, MobilePhone, Email, IsActive from User Where IsActive = true];
        for( User usr : us){
            pickListValuesList.add(usr.name);
        }     
        return pickListValuesList;  
    }

Component:
 
<aura:attribute name="picklistValues" type="String[]" />
	<aura:handler name="init" value="{!this}" action="{!c.doInit}" />

<lightning:combobox name="general" label="Select User" 
               placeholder="Choose User…" value="{!v.User.Name}" options="{!v.picklistValues}" onchange="{!c.doInit}"/>

Controller.js
 
doInit: function (component, event, helper) {
        var action = component.get("c.getPickListValuesIntoList");
        action.setCallback(this, function(response){
                var state = response.getState();
                if (state === "SUCCESS") {
                    var listItems = response.getReturnValue();
                    component.set("v.picklistValues", listItems);
                }
        });
        
        $A.enqueueAction(action);
    }

Please help me from this issue.

Thanks and Regards,
​​​​​​​Azar.
AnudeepAnudeep (Salesforce Developers) 
Hi Azar - Can you try with lightning:select and see if the you are able to select the values?

See this post for sample code