SharePoint 2010 User Profile Page: Add as colleague–Link Fixup


Here’s a small fix for which I didn’t have time to investigate more properly:

Issue

The User Profile Page of another user shows a link “Add as colleague” when that user isn’t already a colleague:

User Profile Page

It seems however that the link behind “Add as colleague” directs to the Default AAM URL rather than the current URL you’re using.

Example:

Zone: Default http://internalserver
Zone: Intranet http://intranet

When browsing to the page using http://intranet the link will refer to http://internalserver. This is not the desired behaviour (think mixed authentication or extranet scenario’s).

Quick fix using jQuery

<script type="text/javascript" src="/my/Style Library/js/jquery-1.7.1.min.js"></script> <script type="text/javascript"> $(function() { var el = $('.ms-my-addcolleague'); if (el.attr('onclick') != undefined) { el.attr('onclick', el.attr('onclick').replace('http:\\u002f\\u002finternalserver:80', '')); } }); </script>

I’m referencing jQuery in the Style Library of the My Site Host, which you need to add or modify the link. I’ve hardcoded the internal URL (default zone public URL), might be better to look that up dynamically but as said this is a quick fix.

You can view the source of your own User Profile Page to find the internal URL for your environment.

You can add this in a Content Editor Web Part to the User Profile page and it should work just fine making the link relative.

Applies to

I’m seeing this issue in a SharePoint 2010 + Service Pack 1 + August 2011 Cumulative Update (14.0.6109.5002). Might be fixed in a later CU or SP.

 


Links to this post

Comments

Friday, 23 Mar 2012 02:17 by David
This is unfortunately not working at all for me. I still see the default AAM in the URL on the status bar when I click the Add as Colleague link, it still fails to load, and I have a permanent JS error referencing 'object not found' in that link. Also the ribbon is broken in page edit mode now.

Monday, 26 Mar 2012 07:04 by Steven Van de Craen
Hi David, If you have any javascript debugging skills feel free to check what's going wrong and let me know if the script needs an update. Could be jQuery not loading or a different output of the page in your version. Cheers.

CAPTCHA Image Validation