Create a nicer looking hyperlink instead of the full URL using simple HTML

Perhaps it is just basic HTML, but I’m positive that this will benefit someone while formatting for example a workflow email.

Instead of having that ugly long URL inside the body of the email, we would like to have some text that says “Click here” to link to the appropriate document / list item etc.

A hyperlink is simply created by typing the following code in  the body of your email:
<a href=”http://MyServerName/”>Click here</a>

Replace the http://MyServerName for some item you would like to link to.

Pretty much all email clients will read the html code and convert it into a nice looking link.

“The template you have chosen is invalid or cannot be found” – Solution

When you receive the error “The template you have chosen is invalid or cannot be found.”  while creating a new site based on a template most likely there are features used in the template that you don’t have in your installation of WSS or MOSS.

This could be because they are simply not activated or because the specific flavor of WSS or MOSS has more features than you have.

Resolving this issue is actually quite easy when you follow the steps described below:

  • Download the STPInspector from: http://stpinspector.codeplex.com/ (we will use the STP Inspector to analyzes the site template file (.stp) and show its dependencies on the site features and site collection features).
  • Install the STPInspector preferably on the server where your installation of WSS or MOSS resides so it can cross reference the site template file’s features against the features available on the server.
  • Download the Microsoft Cabinet Software Development Kit (CABARC) from http://support.microsoft.com/kb/310618 (we will use cabarc for creating a cab file again after we have made modifications to the original manifest.xml file).
  • Create a folder on your c:\ drive called cabarc and extract the files from the executable in there (the name is only important if you want to follow this article by the letter).
  • Create a new folder on your c:\ drive called MySiteTemplateName.
  • Rename your site template file (.stp file) from for example mysitetemplate.stp to mysitetemplate.cab
  • Double click the mysitetemplate.cab file and copy the contents to the folder you just created on your

Making the “Encoded absolute URL” work with a list in SharePoint

You’ve probably noticed that when trying to use the “Encoded Absolute URL” in for example an email that gets sent out from a workflow on a SharePoint list, returns a strange link that doesn’t work when clicking on it.

The URL that gets created when using the “Encoded Absolute URL” looks something like: http://litwaredemo/Project/Lists/Projects/14 .000.

The catch with the “Encoded Absolute URL” parameter is that it only works with Document Libraries – not with any other lists in SharePoint.

There are a couple of easy way around this by changing the URL a bit.

  • Option 1 is the best approach, however you will have to hardcode the server name and this could cause the workflow or other to break when you move servers / domains (not very likely to happen very often though).
  • Option 2 is a straight forward approach which doesnt’ make it necessary to hardcode the server name however has the downside that it will NOT work when using folders inside the list where list items are located.

Option 1: Hard coded server name – best option

When you created a workflow and as an action kick off an email, you can use the “Add Lookup to Body” functionality to compile the link.

In the body of the email type in:
http://YOURSITENAME/

  • Click the “Add Lookup to Body” button
  • For the drop down list “Source” select “Current Item”
  • For the drop downlist “Field” select “Path”
  • Click “OK”
Current Item > Path

Current Item > Path

Now the URL in the email body will look like:
http://YOURSITENAME/[%Tasks:Path%]

  • Enter the text ”/DispForm.aspx?ID=” behind the just inserted parameter
  • Click the “Add Lookup to Body” button again
  • For the drop down list “Source” select “Current Item”
  • For the drop downlist “Field” select “ID”
  • Click “OK”
Current Item > ID

Current Item > ID

Now the URL in the email body will look like:
http://YOURSITENAME/[%Tasks:Path%]/DispForm.aspx?ID=[%Tasks:ID%]

Proper path to SharePoint list item

Proper path to SharePoint list item

 The email that will send out when the workflow is triggered will now look like:

Email with link to list item

Email with link to list item

Option 2: Using [%Tasks:Encoded Absolute URL%]

When you created a workflow and as an action kick off an email, you can use the “Add Lookup to Body” functionality to compile the link.

In the body of the email:

  • Click the “Add Lookup to Body” button
  • For the drop down list “Source” select “Current Item”
  • For the drop downlist “Field” select “Encoded Absolute URL”
  • Click “OK”

Now the following parameter in the email body will look like:
[%Tasks:Encoded Absolute URL%]

  • In order to get a working link we will have to add “/../DispForm.aspx?ID=” behind the just inserted parameter
  • Click the “Add Lookup to Body” button again
  • For the drop down list “Source” select “Current Item”
  • For the drop downlist “Field” select “ID”
  • Click “OK”
  • Now the link in the email body is complete and will look like:
    [%Tasks:Encoded Absolute URL%]/../DispForm.aspx?ID=[%Tasks:ID%]

    The trick is the /../ between the “[%Tasks:Encoded Absolute URL%]” and the “DispForm.aspx?ID=[%Tasks:ID%]” in the link. The “/../” tells the server to go up one level in the folder hierarchy. The problem with this approach is that when you have folders inside your list where you store list items the path to the needs to go up even more levels depending on how deep you nested the list items.

    I recommend using option 1 – but if you are absolutely certain folders will never be used or you will always keep all tasks organized on one specific folder level – this option will be ‘ok’.

    And we are done!

    See our follow up post about creating a nicer looking hyperlink instead of the url.

    Hope this helps!

    Export a SharePoint site as a Site Template (.stp file)

    In SharePoint it’s easy to export your site as a site template and create new sites based on it.

    The site template will save the structure of the site designed in SharePoint Designer, so other sites you create based on the template will have the same structure (optionally you can even include the content!).

    Export a site as a site template using the SharePoint interface.

    • On the specific site you would like to save as a template go to Site Actions → Site Settings;
    • Go to the Look and Feel menu and click Save site as template;
    • The SharePoints administration page “Save Site as Template” will open up from which you can save your site as a template file (.stp). You also have the option to include content which will include the contents of all lists and document libraries in the selected site.

    Export a site as a site template using SharePoint Designer

    • Open the specific site that you would like to save as a template;
    • File → Export → Sharepoint Site Template;
    • The SharePoints administration page “Save Site as Template” will open up from which you can save your site as a template file (.stp). You also have the option to include content which will include the contents of all lists and document libraries in the selected site.

     

    Save site as Template

    Save site as Template

    A few words about included content

    Include content in your template if you want new Web sites created from this template to include the contents of all lists and document libraries in this Web site. Some customizations, such as custom workflows, are present in the template only if you choose to include content. Including content can increase the size of your template. There is a maximum file size of 10MB  for the template file.

    Caution: Item security is not maintained in a template. If you have private content in this Web site, enabling this option is not recommended.

    To learn how to upload and use the template file (.stp),  please read our article: Upload and use a site template (.stp) in SharePoint