$().SPServices.SPGetCurrentUser Issue

Apr 13, 2010 at 11:43 AM
Edited Apr 13, 2010 at 11:44 AM

I cannot seem to get this function to work. Below is the code I have written but not sure what I'm doing wrong. Any help will be appreciated.

<script type="text/javascript" language="javascript" src="SiteLocation/Documents/jquery-1.4.2.min.js"></script>
<script type="text/javascript" language="javascript" src="SiteLocation/Documents/jquery.SPServices-0.5.4.min.js"></script>

<script type="text/javascript">
	$(document).ready(function() {

	var thisDepartment = $().SPServices.SPGetCurrentUser({
	fieldName: "Department",
	debug: true
	});
	
	window.alert(thisDepartment);
	
	});
</scrip>
Coordinator
Apr 13, 2010 at 12:08 PM

This looks right. What is the alert showing you?

M.

Apr 13, 2010 at 12:30 PM

The alert displays nothing.

Coordinator
Apr 13, 2010 at 12:32 PM

Have you tried to get one of the other possible values? Is it just Department that is the issue?

M.

Apr 13, 2010 at 12:44 PM

I've tried a few of them, but it only seems to be returning blank. Is there anything else that could be causing this issue?

Coordinator
Apr 13, 2010 at 1:01 PM
Edited Apr 13, 2010 at 3:47 PM
Are you running WSS or MOSS? Do you get a null response for multiple users? I'll try to reproduce if you give me the details.
M.
Apr 13, 2010 at 1:35 PM

We are using MOSS and i've tried it on a few other users and it still returns null.

Coordinator
Apr 13, 2010 at 4:27 PM

Ah. Silly question, but if you go to the page _layouts/userdisp.aspx?Force=True, are the values populated?  I was just looking in one of my test VMs and was getting no result, but it's because there are no values!  All the GetCurrentUser function is doing is grabbing the available values out of the userdisp.aspx page.

M.

Apr 14, 2010 at 9:28 AM

when I go onto that page, we get redirected to our intranet and to a different page which displays our user information (see url below). I am assuming this is the likely cause of my issue. 

http://site/search/Pages/EmployeeSearchResults.aspx?unm=username

 

Coordinator
Apr 14, 2010 at 11:23 AM

Hmm. It looks like someone on your end may have done a customization that is getting in the way.  Any way you can check on that?

M.

Apr 15, 2010 at 3:18 PM

The team that involved with the customization of this are heavily involved in a client project, so they are really busy. I used an alternative method to achieve the goal I intended through this. Thank you for all your help.

 

I have another scenario:

Would it be possible using SPServices to get the currently logged on user, get a field value (in my case Queue) from another list (which has a field username with the persons name (in the format lastname,firstname) where the logged user equals the persons name. If you have any suggestion your help will be greatly apprecited.

Coordinator
Apr 15, 2010 at 3:21 PM

Yes, but I think you'll have the same issue with SPGetCurrentUser.  Assuming you know the current user, you can use GetListItems with a filter for the current user to the any relevant items from the list.

M.