$().SPServices.SPGetCurrentUser not returning a user ID

May 13, 2014 at 6:27 PM
To start: thanks for this tool. It's really amazing.

I'm having trouble getting my current user's ID -- am using SP2014.01 and jQuery 1.11.1 along with SP2007. I can get the user's name and other fields (depending on which are defined) but I can't come up with the user's ID.

I have a list that has a ShaerPoint User ('Person or Group') as a column and I want to be able to filter results based on the current logged in user using a lookup filter.

Everywhere I look online indicates this should work:
var thisUsersValues = $().SPServices.SPGetCurrentUser({
    fieldNames: ["ID", "Name"],
    debug: false
});
var id = thisUsersValues["ID"];             // doesn't work, 'undefined'
var name = thisUsersValues["Name"]; // works!
Shouldn't ID be a dead set grab ? Thanks.
May 14, 2014 at 11:03 PM
So, I haven't been able to get the ID, but I was able to accomplish my end goal (which was filtering a list result based on the current user). I used this finally.
var userName = $().SPServices.SPGetCurrentUser({ fieldName: "Name" });
 
var query = '<Query>' +
                '<Where>' + 
                    '<Eq>' +
                        '<FieldRef Name="SharePointUser" />' +
                            '<Value Type="User">' + userName + '</Value>' +
                    '</Eq>' +
                '</Where>' +
            '</Query>'; 
 
$().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "UserAccessList",
    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
    CAMLQuery: query,
    completefunc: function (xData, Status) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() {
            // will return only results that match the current logged in user
            // in the 'SharePointUser' column
            console.log($(this).attr("ows_Title"));
      });
    }
});
Marked as answer by thornomad on 8/18/2014 at 8:19 AM