Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

New Post: Return value from GetListItems

$
0
0
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;
    };
});

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>