..:: I like SharePoint ::.. Rotating Header Image

Geschützt: SharePoint 2010 A custom fieldtype for Hyperlinks

Dieser Artikel ist passwortgeschützt. Um ihn anzusehen, trage das Passwort bitte hier ein:


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 ::..

SharePoint 2010 Calling Javascript at page load time

If you want to call your javascript function in a SharePoint Site at page load time, that means, when the page loads – you will have to insert this code snippet:


<script type="text/javascript>
_spBodyOnLoadFunctionNames.push("<code>MyFunctionName");
</code></script>

..:: I LIKE SHAREPOINT ::..

SharePoint 2010 Can i get back my deleted document?

That never happens. Nobody would delete a document which he or she might could need anytime again. There is no reason to care about the deletion of documents and / or elements. Never ever would one of your customers come to you with the question: “Can i get back my deleted documents?”

Exactly, the question is: When is a document really deleted? And for who is the document deleted?

Deletion at frontend

Ok, now i am the normal user with normal rights. I delete a whole list cause i did some mistakes. I go to the list settings and click on delete list.
What happens?

The list is now in the recycle bin (if feature is activated, which is normally). You can recover this list as normal user.

Now i empty the recycle bin. The list dissappears from the recycle bin and i cannot recover this list again. But i need this list really! What can i do?

Help for recovering

In this moment you should be happy, if you know who is your site collection admin and be friendly to him. Because in the site collection administration, there is also a recycle bin. In this recycle bin you now find your list!!! So your site collection administrator is the person who can recover your list.

Below Site Actions – Site Settings – Site Collection Administration you’ll find the recycle bin. It gives you two views on the left pane:

  • End User Recycle Bin items
  • Deleted from end user recycle bin

The first one contains the items which are in the recycle bin at the front end. The second is the interesting one for recovering: It contains all items which are deleted from the frontend recycle bin.

That means: If you delete an item and empty the recycle bin, the item is still available in the recycle bin of the site collection. But this one can only be accessed by the site collection administrator. That is really a nice feature and is also called the second stage Recycle bin.

Last thing: It only works if you have the right settings at the central administration in the settings of the web application:

..:: I LIKE SHAREPOINT ::..

SharePoint 2010: How to create a custom empty application page

You might be wondered what interesting requests you can get. One request i got was to create an application page which does not show the ribbon, the navigation, just nothing but an upload form for a SharePoint document library. The user should not see that he is uploading a file to a SharePoint library and that he is not working on SharePoint.

Sounds easy, but the important thing was to be able to use SharePoint Context and its features in Code. So today i show you how to create this application page which has nothing inside but the possibility to use all SharePoint features.

Step 1: Add an application page to your project into the layouts folder

I name it creazyPage.aspx.

Step 2: Customize the application page

There are some important to do’s:

At first go to your creazyPage.aspx and delete all Placeholders.
That means the following Placeholders: PageHead, Main, PageTitle, PageTitleInTitleArea.

Then delete the DynamicMasterPageFile in the <%@ Page Tag.

Then add the following line before the <%@ Page Tag:


< %@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

You are almost ready. If you deploy now your solution you should get a white page. So let’s proceed.

Now add your content. Start with


<head>
<title>creazyPage</title>
</head>
<body>
<form id="creazyPage" runat="server">
//[[ Here you can add your code like asp Controls or other Controls]]
</form>
</body>

Step 3: Deploy your solution

You solution should now look like this:

A cool trick:

Now if you add asp-Controls you see that you won’t get suggestions which controls are available. If you are smart, then you create your application page in the normal way till it is working as you want it to work . After that you just do the necessary changes described in step 2 and you’re done.

..:: I LIKE SHAREPOINT ::..