Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 13th, 2013  |  syntax: None  |  size: 2.03 KB  |  views: 28  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. var userEmail = '';
  2. var userId    = '43';
  3. $().SPServices({
  4.     operation:      "SearchPrincipals",
  5.     searchText:     "John Doe",
  6.     async:          true,
  7.     completefunc:   function(xData, status){
  8.         $(xData.responseXML).find("PrincipalInfo")
  9.             .each(function(){
  10.                 var thisUser = $(this);
  11.                 if ($.trim(thisUser.find("UserInfoID").text()) == userId) {
  12.                     userEmail = $.trim(thisUser.find("Email").text());
  13.  
  14.                     alert("User's email: " + userEmail);
  15.  
  16.                     return false;
  17.                 }
  18.             });
  19.     }
  20. });
  21.        
  22. CAMLQueryOptions: "<QueryOptions><ExpandUserField>True</ExpandUserField></QueryOptions>",
  23.        
  24. $().SPServices({ operation: "GetListItems", async: false, listName: "Assignees", webURL: "https://col.wow.telenor.com/sites/go/",
  25.             CAMLViewFields: "<ViewFields Properties='True'/>",
  26.             CAMLQuery: "",
  27.             CAMLQueryOptions: "<QueryOptions><ExpandUserField>True</ExpandUserField></QueryOptions>",
  28.             completefunc: function (xData,Status) {
  29.  
  30.                 $(xData.responseXML).SPFilterNode("z:row").each(function () {
  31.  
  32.                     try {
  33.                     //ows_Name1 is a field of type "People or Group" the after adding CAMLQueryOptions this field returns all the fields
  34.                     // propeties of user i.e. Displayname,ID,email id, domain login, sip ID etc all separate by #
  35.                         var title = $(this).attr("ows_Name1");
  36.                     // Splitting the resultant string with # give you string array of all the properties. In my case email ID is at
  37.                     // index 3.
  38.                         var userEmail = userText.split('#')[3];
  39.                     // Below line is added to remove the trailing "," from email id
  40.                         userEmail = userEmail.substring(0,userEmail.indexOf(','));
  41.  
  42.                     }
  43.                     catch (e) {
  44.                         alert('Exception: ' + e.message);
  45.                     }
  46.                 });
  47.             }
  48.         });
clone this paste RAW Paste Data