Hi. I've been looking at this for days now and just can not get it to work. I'm trying to return value "email" outside the function call to a variable called "subEmail". Code is below. Any ideas? The alert does not work.
var subEmail = getSubmitterEmail($userName);
alert(subEmail);
function getSubmitterEmail(userName) {
var _query = "<Query><Where><Eq><FieldRef Name='firstLastName' /><Value Type='Text'>" + userName + "</Value></Eq></Where></Query>";
$().SPServices({
operation: 'GetListItems',
async: false,
webUrl: '/',
listName: '{732DBD98-D0CF-4F7D-8281-4F9D419138D2}',
CAMLViewFields: "<ViewFields><FieldRef Name='Email' /></ViewFields>",
CAMLQuery: _query,
completefunc:
function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
var email = ($(this).attr("ows_Email"));
var isMatch = email.substr(0, 7) == "mailto:";
if (isMatch = "true") {
email = email.substring(7); }
});
} //close completefunc
}); //close SPServices
return email;
};
});