Wednesday, October 5, 2011

Dynamic Hyperlinks in Calculated Columns

I recently was faced with an interesting problem. I needed to create a list column that referenced a field in the list and then dynamically constructed a URL to a filtered view of a document library. Specifically, the users needed to be able to enter the title of a company in a list item, and then have clickable links created that would take them to a separate document library, and only show them documents that belonged to that company.

The solution I implemented was developed by Christophe at Path To SharePoint. His solution was a lifesaver. I give full credit to him. I did find that I had trouble following some of his instructions, so I'm going to post a simplified version of how I implemented it here, along with a few pointers that I uncovered along the way.

The solution is two fold:


  1. Create the list that will hold the name of the company and the hyperlink field
  2. Embed a Content Editor web part in the page that contains a JavaScript that will render the hyperlinks in a friendly manner.

Creating the list:

For illustration purposes, we'll have a list that holds the titles of websites and builds links to their websites dynamically. 

Create a list with a field called "Title". This will hold the name of the website. Next create a field called "Hyperlink". This field will be a calculated field that will dynamically build the hyperlink to the website of that name. 

Enter the following formula in the definition of the Hyperlink field: 


This will  dynamically build a hyperlink of http://www.[Title].com. It will also open the link in a new window. However there's a problem. I created a list item and entered "ESPN" as the website title. Here's what it looks like:



As you can see, the hyperlink isn't exactly user friendly, and it also isn't a clickable link. There is no way I know of to make a dynamically built hyperlink in a calculated field that is user friendly and clickable. Christophe came to the rescue by pointing out that you could embed a content editor web part at the bottom of a page that holds a script that will render the hyperlink correctly.

So, create a web part page, place a list view at the top of the page and place a CEWP at the bottom of the page. You can grab his script at using calculated columns to write html. Make sure that the CEWP is at the bottom of the page. Also, make sure you set the Chrome to 'None' so that the CEWP is completely invisible to the users.

Now when you view your page, it will look like this:



You can see the link now renders correctly, and it is also clickable. Since the hyperlink is a calculated field, you can edit the list item and change the title from ESPN to MSDN. The hyperlink will automatically update.

This is a powerful tool. I was able to use it to link to a filtered view of other document libraries so that only documents belonging to the item in question were displayed.

Thanks to Christophe for the great work.


Saturday, July 2, 2011

Creating Managed Paths Using SQL and STSADM

I recently had to stand up a WSS 2.0 development environment for for a client. They had multiple web apps with over a thousand site collections - each with a managed path. Creating a thousand managed paths in Central Administration manually would not only be time consuming, but if a manually typed in managed path contained a typo, the content would not render in SharePoint when the content database was attached.


To resolve this problem I used the following process to create over a thousand managed paths in a few minutes using SQL and STSADM.

• Execute the following query against the content database:

Select 'stsadm -o addpath -url ' + FullUrl + ' -type explicitinclusion' from Sites Order By FullUrl

• This results in a list of stsadm commands that will create the desired managed paths as shown below:

 
The next step is to copy the resulting text into a batch file. Give the batch file a descriptive name and place it into the directory alongside the STSADM.EXE file.




The final step is to simply open a command prompt and execute the batch file. Once the operations complete, open Central Administration and your managed paths will be installed.




This was a quick, easy way to automate what would have been a tedious task.

Thursday, March 31, 2011

The request failed with HTTP status 401: Unauthorized

I recently implemented a SharePoint farm with Reporting Services installed on a remote server in SharePoint Integrated mode. After configuring everything and uploading a report a document library, I received the error "The request failed with HTTP status 401: Unauthorized" when I tried to manage the report subscriptions from a client machine. I was able to access all the Report Server functions as long as I was on the server itself, but as soon as I moved to a client machine - no luck.

Research indicated that the proper solution was to enable Kerberos and make sure that the servers and accounts invloved were setup properly for delegation, and that the correct SPN's existed. For a variety of reasons, this was not possible and I needed to find a way to resolve the issue outside of Kerberos.

The work around was to configure the Reporting Services integration in Cemtral Administration to use a Trusted Account rather than Windows authentication. Here's the steps needed to accomplish that:

Open Cntral Administartion and click General Application Settings:



 Next, select Reporting Services Integration:


Next, change the Authentication mode from Windows Authentication to Trusted Account. Enter credentials of an account that is an administrator

Monday, February 7, 2011

User Cannot Approve Task - Access Denied

I created a SharePoint Designer workflow that assigns an approval task to a user when a list item is created. I began receiving reports that users were receiving the task emails from SharePoint, but when they attempted to approve or reject the task they received "Access Denied" .

Further troubleshooting showed that they had access to the task library, and could see the tasks, but they could not open any of their tasks. I broke inheritance and gave the users "Full Control". This did not resolve the issue.

I found mentions on the webthat publishing the workflow files to the local file system resolved this issue. As crazy as it sounds, this resolved my issue. Here are the steps I took:

Open SharePoint Designer and browse to the workflow in question. Right click on the workflow and select "Publish Selected Files"


Select the radio button labeled "Local File System", and browse to any area on your local drive:



If you receive a dialog stating that no website exists and asking if you wish to create it, click yes. Allow the files to be copied to your local drive.

At this point, my users were once again able to approve their assigned tasks.

Friday, February 4, 2011

SharePoint 2010 Alternate Access Mapping

I recently got tripped up while setting up Alternate Access Mappings on a test server I was using for development.

I built a Share Point Foundation farm using the default as the default URL. I needed to mimic a client environment to use "TheHub" as the default URL for demonstration purposes.

I followed the step by step instructions found on TechNet for accomplishing this, (Located Here), but I was still unable to browse my site.

Here are the high level steps for accomplishing this task:

  1. The first step is to disable the loop back check on the server. In my case, this was a test server, so I was doing development and browsing the site from the server itself. Until you disable the loopback check, you will not be able to hit the site successfully with the new URL. I used method 2 located here.
  2. Next, Open Central Administration /Application Management/Configure Alternate Access Mappings and create a new internal URL as described here.
  3. The next step, and the one I neglected, is to open the hosts file located at C:\Windows\System32\drivers\etc and add an entry for 127.0.0.1 and point it to the new URL. You'll need to open Notepad with 'Run As Administrator' permission in order to do this. For more information on editing the host file, check out this article: Creating Entries in the Hosts File.
  4. The final step is to go back into Central Administration /Application Management/Configure Alternate Access Mappings  and select "Edit Public URLs" from the menu, and swith the entries so that the new URL is in the default text box and the servername entry is in the intranet text box and click Save.
This will insure that SharePoint uses the new URL as the default URL; otherwise alerts and other emails will go out using the servername instead of the desired URL.

Monday, January 24, 2011

Could Not Find Feature TransMgmtLib

Recently I had to move a client from MOSS 2007 to SharePoint Foundation. There were several problems that I encountered in this process. Microsoft provides few paths for downgrading while moving to a new version.

One the the errors I encountered was "Could Not Find Feature TransMgmtLib" when importing a site. This error occurs when the MOSS site you are moving had features installed that the SharePoint Foundation installtion does not.

I resolved this issue by the following process:


You will need to install the following features in your SharePoint Foundation farm:

1.SlideLib

2.TransMgmtLib

3.RelatedLinksScopeSettingsLink.

4.BaseWeb

5.ReportListTemplate

6.Dataconnectionlibrary

7.BizAppsListTemplates

8.PremiumWeb

By default, SharePoint Foundation does not have the above listed features. You will need to copy them from MOSS to SharePoint Foundation. You will find the above mentioned feature on MOSS server in the C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES folder.

Copy the feature to the following folder on SharePoint Foundation Server:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES

Once copied, you can install all these feature using the following command.

Stsadm -o installfeature -name  –force

Example:  stsadm -o installfeature -name slidelibrary -force