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
Tyler ZikaTyler Zika 

populate ui:inputSelect with users from org.

I have a form that you can create an item and assign the item to a user in an org. I want to display the user names in the inputSelect, but when the form creates the new item, saves the users Id
 
<div>
    	<h1>New Whiteboard Item</h1>
        <ui:inputText label="Name" aura:id="name" value="{!v.newWhiteboardItem.Name}" />
        <ui:inputDate label="Due Date" aura:id="ItemDueDate" displayDatePicker="true" value="{!v.newWhiteboardItem.TouchpointDev__Item_Due_Date__c}" />
        <ui:inputSelect label="Assign To" aura:id="ItemAssignTo" value="{!v.newWhiteboardItem.TouchpointDev__AssignedTo__c}" />
        <ui:inputCheckbox label="High Priority" aura:id="ItemHighPriority" value="{!v.newWhiteboardItem.TouchpointDev__High_Priority__c}" />
        <ui:button label="Save" press="{!c.newWhiteboardItem}" />
</div>

In the doInt function I have this
loadOrgUsers : function(component) {
        var orgUsersDB = component.get("c.getUsersDB");
        orgUsersDB.setCallback(this, function(response) {
        var state = response.getState();
        if(component.isValid() && state == "SUCCESS") {
            console.log(response.getReturnValue());
            component.find("ItemAssignTo").set("v.options", response.getReturnValue());
        }
    });
    $A.enqueueAction(orgUsersDB);
},
The console.log returns an array of objects the the users Id and Name. The picklist is blank, but there are 4 blank rows, so it looks like I need to choose whether to display the user name or id, obviously the name. How do I do that?
 
Balasubramaniam 07Balasubramaniam 07
Hi 
You have to use inputselectoption,
Try this
<aura:attribute name="AssignTo" type="string[]"/>
​  <ui:inputSelect class="slds-select" aura:id="opt">
                        <aura:iteration items="{!AssignTo}" var="s"> 
                            <ui:inputSelectOption text="{!s}"/> 
                        </aura:iteration>                    
                    </ui:inputSelect>

controller
component.set("v.AssignTo", response.getReturnValue());

Thanks,
Bala