This project has moved and is read-only. For the latest updates, please go here.

Firefox issue FF - GetUserProfileByName

Aug 11, 2011 at 6: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 8:28 PM

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

Aug 12, 2011 at 4: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 3: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.

Aug 16, 2011 at 12:17 AM
Edited Aug 16, 2011 at 12:17 AM

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 2: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!

Aug 16, 2011 at 2:32 PM

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

M.

Oct 28, 2011 at 4: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?

Oct 28, 2011 at 4: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.