Firefox issue FF - GetUserProfileByName

Aug 11, 2011 at 5:44 PM

Hi. Not sure why this works in IE but not FF.  Any thoughts? Please.

<script type="text/javascript" src="MYPATH/jquery-1.4.1.min.js"></script>
<script type="text/javascript" language="javascript" src="MYPATH/jquery.SPServices-0.6.1.min.js"></script>

<script language="javascript" type="text/javascript">
 
$(document).ready(function() {
 
  var userDepartment;
  var userDirectNumber;
  $().SPServices({
    operation: "GetUserProfileByName",
    async: false,
    AccountName: $().SPServices.SPGetCurrentUser(),
    completefunc: function (xData, Status) {
      userDepartment = $(xData.responseXML).find("PropertyData > Name[text='Department']").parent().find("Values").text();
    }
  });
  alert(userDepartment);
  $("input[Title='Department']").val(userDepartment);
 
/*end*/
});
 
</script>

Aug 11, 2011 at 7:28 PM

Sorry, so this code was added to a CEWP on the newform.aspx of a list.

Coordinator
Aug 12, 2011 at 3:03 AM
nyalex:

When you say that this doesn't work in FireFox, what does happen? Are you getting results from the Web Service call?

First thing I'd do is get your jQuery up to date. You're using 1.4.2, and the current version is 1.6.2. Then I'd do some debugging with Firebug.

M.
>
Aug 12, 2011 at 2:50 PM

The dept value is not placed in the dept column. 

I then added an alert but the alert does not display any information as well.

Yes, good point, I updated to 1.6.2.

Coordinator
Aug 15, 2011 at 11:17 PM
Edited Aug 15, 2011 at 11:17 PM

This works the same in both browsers:

  var userDepartment;
  $().SPServices({
    operation: "GetUserProfileByName",
    async: false,
    AccountName: $().SPServices.SPGetCurrentUser(),
    completefunc: function (xData, Status) {
     $(xData.responseXML).find("PropertyData > Name:contains('Department')").each(function() {
      userDepartment = $(this).parent().find("Values").text();
     });
    }
  });
  alert(userDepartment);

 M.

Aug 16, 2011 at 1:31 PM

You are unselfish when you respond to these requests.  Your willingness to help people is even better then the tech solutions you provide.  I was able to complete this portion of my project with your solution.  Thank you so much!

Coordinator
Aug 16, 2011 at 1:32 PM

It's great to hear that you got it done, and thanks for the kind words!

M.

Oct 28, 2011 at 3:05 PM
sympmarc wrote:

This works the same in both browsers:

  var userDepartment;
  $().SPServices({
    operation: "GetUserProfileByName",
    async: false,
    AccountName: $().SPServices.SPGetCurrentUser(),
    completefunc: function (xData, Status) {
     $(xData.responseXML).find("PropertyData > Name:contains('Department')").each(function() {
      userDepartment = $(this).parent().find("Values").text();
     });
    }
  });
  alert(userDepartment);

 M.


Can this be easily extended to create multiple variables, i.e. Department, Manager, etc?  Without having to do a whole new GetUserProfileByName?

Coordinator
Oct 28, 2011 at 3:08 PM

Sure. The example above just grabs the Department; the other available values are in the returned XML, so all you need to do is pull them out.

M.