SharePoint 2010 One possibility to filter hyperlinks

SharePoint and hyperlinks – this is really curios. If you ever used the column type hyperlink in a SharePoint list, you may know what i mean. Hyperlinks are available but with limited functions:

  • No filtering possible
  • No option to open it in a new window

The hyperlinks automatically open the webadress in a new window if you are in detail view of an item, but not in the listview. But you can check the hyperlink at inserting – great! That means, if your customers wants to manage some web applications in a list and requires that the link opens in a new window at the listview and that he can filter and sort these web applications, you have to find a way to get it that way working. Well, you could write a custom fieldtype. But that means writing code, deployment steps and testing as well as maybe some more things to do (documentations).

But let’s think about some other standard features SharePoint offers to get it working:

Feature 1: A column from type text

  • is filterable
  • displays the whole hyperlink, not only the description
  • does not open the hyperlink in a new window

Feature 2: A column from type multicolumn

  • is not filterable
  • if rich text editor is opted, can display the desciption
  • is able to open the link in a new window

Feature 3: A column from type calculated

  • same as Feature 1

Feature 4: A column from type Hyperlink with formatting and constraints for publishing

Seems like a nice opportunity to be creative and think about mixing the things up. What about using two columns – one for the hyperlink and one for the display? Well, if we have www.ilikesharepoint.de as webapplication then we know between www. and .de there is the application name.

One option for the hyperlink problem

The possibility shown below uses InfoPath in order to customize the list forms, therefore you need SharePoint Server Enterprise licence and you need the SharePoint Designer.

Step 1: Create a column from type hyperlink and call it “webapplicationlink”

Step 2: Create a column from type text and call it “webapplication”

Step 3: Add a formula to the webapplication field to get the name of the webapplication

The text field should not appear in the New, Edit and Display form of the list and it is filterable.  In this case you need to change the listforms. You need therefore the InfoPath Designer. Open the list and the list tab and click on “Customize Form” Button.

*Remember: Therefore you need the enterprise licence

Now you can use the InfoPath formulas to retract the name of the link from itself and make the field webapplication hidden in the form. It is important, because this column you can filter in the listview, therefore this column should save some nice values.

If you need a nice overview of formulas you should look at this page.

Step 4: Change the view of the listview with SharePoint Designer

Open the view of the list and click at Options the Customize XSLT Style for the view. Search for the viewfields tag and make sure that for the column “webapplicationlink” the attribut “exclusive” is set to true. That adds the column to the view but it is not visible. Makes sense, because we don’t want to show the hyperlink column itself but get its value. The nclick in the draft view on the element of the calculated column and look at the source code. There you’ll find this part:



<xsl:template name="FieldRef_Text_body.webapplication" ddwrt:dvt_mode="body" match ="FieldRef[@Name='webapplication']" mode="Text_body" ddwrt:ghost="show">
<xsl:param name="thisNode" select="."/>
<xsl:choose>
<xsl:when test="@AutoHyperLink='TRUE'">
<xsl:value -of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping ="yes"/>
</xsl:when>
<xsl:otherwise>
<xsl:value -of select="$thisNode/@*[name()=current()/@Name]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


Replace it with this



<xsl:template name="FieldRef_Text_body.webapplication" ddwrt:dvt_mode="body" match ="FieldRef[@Name='webapplication']" mode="Text_body" ddwrt:ghost="">
<xsl:param name="thisNode" select="."/>
<xsl:variable name="desc" select="$thisNode/@webapplicationlink.desc" />
<xsl:variable name="url" select="$thisNode/@webapplicationlink" />
<a href="{$url}" target="_blank"><xsl:value -of select="$desc" /></a>
</xsl:template>

<a href="{$url}" target="_self"><xsl:value -of select="$desc" disable-output-escaping ="yes" /></a>


Remember to exchange the field names with your own field names. Well, now look at your solution. What happens? If you create a new entry, you insert a hyperlink into a hyperlink field. In Display mode you see the hyperlink with description and it opens the hyperlink in a new window. So far so good.

If you go to the listview, you do not see the hyperlinkfield. You only see the calculated field and you have these options:

  • column is filterable
  • hyperlink opens in a new window
  • hyperlink is displayed with a nice description

In this case you used some standard features of SharePoint, combine them and make a little bit customizing at listview – that’s it!

What are your experiences? How did you solve the problem? I would like to hear your solutions.

..:: I LIKE SHAREPOINT ::..

The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

Karsten Pohnke About Karsten Pohnke
He is Consultant for SharePoint Solutions for collaboration, communication and business processes. He provides his customers applications based on standard features as well as development or combining the power of several microsoft tools like Dynamics CRM. In his free time he tries to collect tipps and worthy experience in this blog.

Submit comment

Allowed HTML tags: <a href="http://google.com">google</a> <strong>bold</strong> <em>emphasized</em> <code>code</code> <blockquote>
quote
</blockquote>

Please fill in the captcha: * Time limit is exhausted. Please reload CAPTCHA.