This project has moved and is read-only. For the latest updates, please go here.

ExpandUserField Not Working

Oct 13, 2011 at 2:32 PM
Edited Oct 13, 2011 at 2:35 PM

I was reading in this article that you can pull a user's email from a person field by adding in the following code: "<QueryOptions><ExpandUserField>TRUE</ExpandUserField></QueryOptions>".  It doesn't seem to work for me.

I'm trying to get the last 10 items that have been modified.  There is a person field that should be getting returned with it and I'm assuming it would automatically pull that extra information from that field. 

In the callback function, the status parameter comes back "success" and in the data object status is 200, statusText is "OK" and responseXML.text is an empty string.  The posts variable that this is getting set to will just be undefined.  If I leave the QueryOptions out it will work but it won't get the user's email, which is my ultimate goal (so if there's another way to go about this I'd appreciate that too).  Let me know if you need to know anything else.  

Here's the full code I'm using.  Thanks!


var posts = $().SPServices({
            operation: "GetListItems",
            async: false,
            listName: "Leadership News",
            viewName: undefined,
            CAMLViewFields: undefined,
            CAMLQuery: "<Query><OrderBy><FieldRef Name='Modified' Ascending='False' /></OrderBy></Query>",
            CAMLRowLimit: 10,
            CAMLQueryOptions: "<QueryOptions><ExpandUserField>TRUE</ExpandUserField></QueryOptions>",
            completefunc: function (data, status) {

                if (status === "success") {
                    items = new Array();

                    $(data.responseXML).find("[nodeName='z:row']").each(function () {
                        row = new Array();

                        $(this.attributes).each(function () {
                            row[] = $(this).val();

                        items[items.length] = row;
                } else {
                    if (debugConsole) {
                        console.log("getListItems: Syntax Error: unable to lookup lists");

                if (items !== undefined) {
                    if (items.length === 0) {
                        items = undefined;

                if (async) {
                    asyncComplete(status === "success", items);
Oct 23, 2011 at 4:33 AM

Sorry for the delayed response.

You're passing "undefined" for several of the optinos, which is probably making the cal fail. If you don't want to pass in a value for an option, simply omit it.

In the completefunc, add


to see what is returned.