I'm having trouble getting a user's info using SP Services from a sub-site. Using the code below I get the error There are multiple root elements.

var employeeName = $(this).attr('ows_Employee');
var employeeInfoViewFields = '<ViewFields>\
                                <FieldRef Name="Title" />\
                                <FieldRef Name="Department" />\
                                <FieldRef Name="JobTitle" />\
                                  <FieldRef Name="Title" />\
                                  <Value Type="Text">' + employeeName + '</Value>\
  operation: 'GetListItems',
  async: false,
  listName: 'UserInfo',
  // listName: 'User Information List',
  CAMLViewFields: employeeInfoViewFields,
  completefunc: function(xData, Status) {
    // Do stuff

I eventually replaced SPServices with a standard ajax call. This works perfectly.

  url: "/_api/lists/getbytitle('User Information List')/items?$filter=Title eq '" + employeeName + "'&$select=Department,JobTitle",
  type: "GET",
  async: false,
  success: function (xml) {
    department = $(xml).find('d\\:Department, Department').text();
    jobTitle = $(xml).find('d\\:JobTitle, JobTitle').text();
  error: function (a, b, c) {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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