0

I have a form that contains an element of type SPUser like this picture : enter image description here

It's a combox witch contains the name of SPUser.Does any one have an idea.

I am using SharePoint foundation 2013.

4
  • Please add more details to the question. Are you looking to populate all users available in site? Post relevant code which gives you the current screen. Dec 18, 2014 at 13:34
  • I need to create a combobox witch contain SPUser's name.
    – Imen Turki
    Dec 18, 2014 at 13:43
  • if you want to fill it dinamically, you can access through SPWeb.AllUsers or SPWeb.Users, this will return a SPUserCollection,then loop it and get SPUser.Name
    – Marco
    Dec 18, 2014 at 13:51
  • this is with REST API : _api/web/siteUsers
    – Imen Turki
    Dec 18, 2014 at 14:27

1 Answer 1

0

You can use CSOM for getting all site users, use following example

var collListItem;
function GetAllUsers()
{
    var clientContext = new SP.ClientContext.get_current();
    var web = clientContext.get_web();
    var userInfoList = web.get_siteUserInfoList();
    collListItem = userInfoList.getItems();
    clientContext.load(collListItem);
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),Function.createDelegate(this, this.onQueryFailed));
}

function onQuerySucceeded(sender, args)
{
    //Iterate through CollListItem and fill the combobox
}

function onQueryFailed(sender, args)
{
    alert('Failed');
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.