function dowork() {
var email = 'xxx@xxx.onmicrosoft.com';
var userlogin = getuserfromemail(email);
alert(userlogin);
}
function getuserfromemail(email) {
// get userlogin from user email as recorded in systemLanguage
"use strict";
var e = "<Users><User Email='" + email + "'/><Users>"; // tried both ways
var e = '<Users><User Email="' + email + '"/><Users>'; // this is the correct email - I've checked many times.
var userlogin = null;
alert(e);
// below results in error status - Bad Request
$().SPServices ( {
debug: true,
operation: "GetUserLoginFromEmail",
emailXml: e,
async: false,
completefunc: function(x,status){ alert(status + " status"); console.log(x);
console.log(x.responseText.text);
console.log(x.responseXML.xml);
$(x.responseXML).find("User").each(function() {
alert("each");
var user = $(this);
userlogin = user.attr("Login")
var userdn = user.attr("DisplayName");
alert (userlogin + " " + userdn);
}) // each
} // completefunc
}); // spservices
// below an example from jack which works.
/*
$().SPServices({
operation: "GetUserLoginFromEmail",
emailXml: "<Users><User Email='jack_harry@goodworld.net'/></Users>",
completefunc: function (xData, Status) {
$(xData.responseXML).find("User").each(function() {
$(this).attr("DisplayName");
})
}
});
*/
return userlogin;
} // getuseridfromemail
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.