This project has moved. For the latest updates, please go here.

SPGetCurrentUser not working for anything other than "ID"

Oct 16, 2014 at 2:47 AM
Edited Oct 16, 2014 at 2:51 AM

I can only pull current user's ID and nothing else. So, a code like below comes back as empty.

var user = $().SPServices.SPGetCurrentUser({ fieldName: "Title", debug: true });

Changing the "Title" to "ID" works fine. Also, due to the above, the GetUserGroups function is not working -
operation: "GetGroupCollectionFromUser",
         userLoginName: $().SPServices.SPGetCurrentUser(),
Fails completely. I checked the XML and it is failing to pass in the username.

Note: using jquery-1.10.2.min.js and jquery.SPServices-2014.01.min.js. Environment is SP 2013 Foundation SP1.

Oct 16, 2014 at 3:03 AM
Are you making the calls from the root Site Collection, i.e., http://servername/? M.
Oct 16, 2014 at 3:05 AM
Yes, the script is running at the root. Is that an issue?
Oct 16, 2014 at 3:37 AM
Noticed this message in console - XMLHttpRequest for http://_layouts/userdisp.aspx?Force=True&1413430567158 required Cross Origin Resource Sharing (CORS).
So, looks like a root site collection URL issue.
Oct 16, 2014 at 1:43 PM
Yeah, I have a bug in the function when it is used in the root site. See:

I've just uploaded a new alpha (2014.02ALPHA5) with a fix for those two issues and a couple other things. Can you try it out?

Oct 16, 2014 at 7:50 PM
Hi Marc

Thanks for the fix but I am unable to see the new uploaded file on the link above.

Oct 16, 2014 at 7:55 PM
Just to update that I replaced the code from the work item into my stable release copy and it is working now.

Oct 17, 2014 at 12:23 AM

Oct 17, 2014 at 3:30 AM
BTW, keep in mind that it's an alpha, but it should be stable.