Query the User Information List with jQuery and Web Services

Jim Bob Howard and I have been going back and forth thinking about this for a few days now.  You’re not going to believe how simple the answer is! I found a post that told me the simple answer: Just query the list like any other list!

Here’s the simple test I just did in my test environment:

$(divId).html(waitMessage).SPServices({
  operation: "GetListItems",
  webURL: "/",
  listName: "User Information List",
  completefunc: function (xData, Status) {
    var out = $().SPServices.SPDebugXMLHttpResult({
      node: xData.responseXML,
      outputId: divId
    });
    $(divId).html("").append("<b>This is the output from the GetListItems operation:</b>" + out);
  }
});

Similar Posts

12 Comments

  1. Marc,

    I have been using your library to update this list. I created extra fields in my site definition and then users update the data when they first enter the site. It really is neat!

    speg

  2. I have two lists called Department and Projects. In projects list I have a lookup column DptID mapped to ID value in Department list. I have two Dropdown fields called Budget and Time in both the lists.

    When Creating a new project, I pass DptId in Query string of page and pass it in to lookup column field using Javascript.

    Ex: Dpt List : Item-1 ID-1 , Buget- less than 50,000 , Time – less than 6 months
    Item-2 ID-2 , Buget- less than 150,000 , Time – less than 12 months

    For New Project Item If DptID =2 then default dropdown values for Budget and time should be same as Item2
    My Question is how do I set default values in Budget and Time fields on New project form same as corresponding values in Department Item. and let user change if they want to..

    1. siva:

      If I understand what you’re doing correctly, you could either pass the defaults on the Query String or use the Lists Web Service to read from the Department list for your defaults.

      M.

  3. Hi Marc, I want to auto populate a field when a look up field (drop down)(in the same list) selection is changed, with the value from the look up list. Sorry for the bad explanation. Hope the below scenario helps you understand better
    List A-
    column 1-(look up from List B, Column 1)
    Column 2-(people picker, to be auto populated with value of column 2(people picker)- List B when column 1 in list A and B match)

    Would be grateful if you can help.

    Thanks

    1. badhon:

      You’ll need to bind to the change event for column 1 (more complex if it has 20+ values) and then populate the People Picker. The new SPFindPeoplePicker function in v0.7.2 (currently beta) should help.

      M.

      1. Thanks a lot Marc!!! :)
        It’s a lot of fun following you. One more tricky (i think) thing I am stuck with is:
        There are multiple people picker fields in a list. i need to make one of them read-only for certain users in certain scenarios. i am using spservices to find if the logged in user is part of a certain group and then using j-query to make that ‘one’ people picker field read-only. I have been able to achieve it but i had to use the ‘id’ (whose value is not in our hands) of the control instead of its ‘title’ (display name of the field in list-form). Is there a way to get this done using the ‘title’ of the field.
        P.S.- all the people picker controls’ ‘title’ is same (= People Picker) on the form unlike other type of controls whose title comes as their respective display name.

        1. Badhon:

          Take a look at the new SPFindPeoplePicker function in SPServices v0.7.2. It won’t disable the People Picker for you, but if you look at the code you’ll be able to see how I find the right People Picker.

          M.

  4. When I run the code as stated in your blog post, I get the infamous “GUID must be…” error message. When I replace “User Information List” with “UserInfo,” everything comes out fine.

      1. Michael:

        You don’t have to be an administrator, but you do have to have permissions to read the User Information List.

        M.

  5. I am trying to update “Author” column with user information passing from a function using SPService.

    One observation: Author column is read only by default, made it ReadOnly as false using below code
    var markReadOnly = ”;
    markReadOnly += ”;
    markReadOnly += ”;

    Evan after making readonly = true
    Author column did not updated with the username passed (domain\username)

    Please let me know, is there other approach doing using SPServices
    –Santosh

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.