Monday, August 2, 2010

Overriding SharePoint My Profile: Ask me About (Expertise) links

My Profile home page comes with a Ask Me About web part. Which is nothing but a list of Expertise each user would have updated the User Profile to let the others know about the expertise.
Any users who browser through the profile and clicks on the Expertise link then it will open up in the Noteboard web part. This posts the question to the person who has updated the expertise.
If the Noteboard web part is disabled then it opens the question in the Mail client available in the machine.

There was some bug in this that it opens up a mail client and also a blank browser window. On closer observation found that clicking on the Expertise link was calling a Java Script function NavigateToNoteboard().
This javascript was coming from the WebPart whose page, I was not able to find or did not want to change as it was a standard web part being used every where.

This is where I figured out that you could override javascript and the behavior is that the last javascript in a page overrides the others. So a simple hack of overriding this javascript immediately after the Web Part control registration solved the problem.

Here is the link that I used in my overriden Javascript for opening the question in  a mail client.

http://www.webmasterworld.com/javascript/3290040.htm


document.location.href = "mailto:" + toAddress + "?subject=" + subject;

Hope this was useful.. In the above, I was able to showcase
  1. The bug that opens a blank web page when Noteboard web part is removed.
  2. Overriding the Javascript
  3. Opening a mail client through JavaScript

1 comment:

  1. I found another way to avoid the extra browser window.
    Check the security settings in IE. Make sure that "Enable Protected Mode" is either on or off for all zones. Once all zones are the same you should no longer get the blank IE window.
    /Fred

    ReplyDelete