SPGetCurrentUser not working for anything other than "ID"

Oct 16, 2014 at 3:47 AM
Edited Oct 16, 2014 at 3:51 AM
Hi

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 });
alert(user);

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.

Cheers
Coordinator
Oct 16, 2014 at 4:03 AM
Are you making the calls from the root Site Collection, i.e., http://servername/? M.
Oct 16, 2014 at 4:05 AM
Yes, the script is running at the root. Is that an issue?
Oct 16, 2014 at 4: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.
Coordinator
Oct 16, 2014 at 2:43 PM
Yeah, I have a bug in the function when it is used in the root site. See:
https://spservices.codeplex.com/workitem/10277
and
https://spservices.codeplex.com/workitem/10272

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?
https://spservices.codeplex.com/releases/view/119578

M.
Oct 16, 2014 at 8:50 PM
Hi Marc

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

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

Cheers
Coordinator
Oct 17, 2014 at 1:23 AM
Excellent!

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

M.