SPServices.SPGetCurrentUser can only get ID

I want to get current user information using SPServices.SPGetCurrentUser, however, it can only get ID, the Name and other Fileds are always null.

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script> <script type="text/javascript" src="../Code/jquery.SPServices-0.7.2.js"></script> <script type="text/javascript"> $(function() { var thisUserID = $().SPServices.SPGetCurrentUser({ fieldName: "ID", debug: false }); alert("ID: "+thisUserID);

var thisUserAccount = $().SPServices.SPGetCurrentUser({ fieldName: "Name", debug: false }); alert("Name: "+ thisUserAccount); }); </script>


Can you tell me the reason and how to resolve it?




June 19th, 2015 3:00am

Dear all,

I only want to use spservice to get current user information using the code above.

Can you tell me why it don't work?

Thanks,




Free Windows Admin Tool Kit Click here and download it now
June 23rd, 2015 3:24am

Hi,

In my environment, I can use the code snippet like below to alert the user name:

<script type="text/javascript" src="http://sp2013sps/sites/test1/Shared%20Documents/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="http://sp2013sps/sites/test1/Shared%20Documents/jquery.SPServices-2014.02.min.js"></script>

<script language="javascript" type="text/javascript">
   $(document).ready(function() {
        //  Set the 'Title' input field to the current user's "Title" property
       var userName = $().SPServices.SPGetCurrentUser({
            fieldName: "Title"
        });
       alert(userName);
    });
</script>

For a better troubleshooting, I suggest you can check if the current user has a valid account Title value. Also, I suggest you can try to use other accounts to check if the SPService can work as expected.

Thanks

Best Regards

June 23rd, 2015 9:54pm

Hi Jerry,

I can login the site sucessfully, so I have the title or Name.

However, I can only get the ID.

I'm using SharePoint 2010 not 2013.

Does it have permission setting to limite the spservice?

In other word, I'm site admin. Is it the permission issue to use spservice?

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../Code/jquery.SPServices-0.7.2.js"></script>

<script type="text/javascript">

$(function() {  
  
        alert(1);
	
        var thisUserID = $().SPServices.SPGetCurrentUser({
		fieldName: "ID",
		debug: false
	});
        alert("ID: "+thisUserID);
        var thisUserAccount = $().SPServices.SPGetCurrentUser({
   fieldName: "Title",
   debug: false
  }); alert("Title: "+ thisUserAccount); alert(3); }); </script>

Thanks




Free Windows Admin Tool Kit Click here and download it now
June 23rd, 2015 10:46pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics