$().SPServices.SPGetCurrentUser works for some fields but not others

Oct 31, 2013 at 9:14 PM
First of all, thank you for providing this valuable library. I've read several threads about SPGetCurrentUser and I thought I had it worked out. But here is my specific situation. If created a simple snippet just to test the code provided in your exmaples:
<!-- Reference jQuery on the Google CDN -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" type="text/javascript"></script>
<!-- Reference SPServices on cdnjs (Cloudflare) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2013.01/jquery.SPServices-2013.01.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">

$(document).ready(function() {
   var thisUserAccount = $().SPServices.SPGetCurrentUser({fieldName: "Name", debug: false   });
   alert( "thisUserAccount: " +thisUserAccount);

   var thisUserName = $().SPServices.SPGetCurrentUser({ fieldName: "Title",debug: false   });
   alert( "thisUserName: " +thisUserName);

   var thisUserID = $().SPServices.SPGetCurrentUser({fieldName: "ID",debug: false   });
   alert( "thisUserID: " +thisUserID);
});
</script> 
Both alerts for thisUserAccount and thisUserName return blanks, but thisUserID returns a value. This leads me to believe that the calls are functioning, but I'm scratching my head as to why some calls return values and some do not.
Coordinator
Oct 31, 2013 at 9:17 PM
Edited Oct 31, 2013 at 9:20 PM
Are you by any chance making the calls from the root site in the Web App? i.e.,
http://servername/
M.
Nov 1, 2013 at 11:07 AM
Marc

By chance I am :) (http:/servername/lists/mylist/allitems.aspx). I copied the code to a sub-site and the calls work. Is there a limitation or alternate technique for it to work at the root?
Coordinator
Nov 1, 2013 at 12:53 PM
There's a bug. I have it fixed in the latest alpha.

The fix for you now if to add the webURL option with a value of "/". When I do the next release, that will continue to work, but will no longer be necessary.

M.
Nov 1, 2013 at 10:53 PM
Thanks.

BTW, for one site the "/" wasn't sufficient, so I tried 'http://servername" which worked fine. I'm using document.host for the time being.

Steve
Coordinator
Nov 1, 2013 at 11:44 PM
It should work in subsites fine. The bug should only occur in the root site of the Web App.

M.