Workflows and URL links to document items

December 1, 2009

It has been a while since I posted so here is a good one.  For a while I have been struggling with getting a URL for a document item view, it just doesn’t exist as a whole in any SharePoint property.  The kicker is that you have to concatenate a few variables to create any URL you may want to email a user from a workflow (this is my delima).  Say I want to complete a workflow and send a link to the document meta data for user review.  Whoaaa there fella, not so fast…you are using SharePoint after all….

So after countless attempts to create a URL it turns out it is very difficult since each part of the string doesn’t exactly match what I needed to use.  For instance, the site url and web url properties of a worflowproperties object, result in http://hostname/sites/site and the list url includes the same information sites/site/docuemntlibrary (someone said to use the List name property but I almost always create my libraries with a short name then rename it with a longer more descriptive name).

So I am left with a challange, I need to find a property that has the hostname url of the SharePoint web application.  Easy right?  Nope, as our friend Borat would say “Not So Much”.

So the first set in getting your hostname URL is create the following function:
Private Function LocalWebUrl() As String
Dim localUrl As String = Nothing
Using web As SPWeb = workflowProperties.Site.RootWeb
Using site As SPSite = web.Site
For Each altUrl In site.WebApplication.AlternateUrls()
If altUrl.UrlZone = Administration.SPUrlZone.Default Then
localUrl = altUrl.IncomingUrl.ToString
End If
End Using
End Using
Return localUrl
End Function

At this point we have only gotten a short peice of what we need overall.  http://mysharepointurl is basically all we have accomplished, but you do have the ability to get at an alternative URL if needed (perhaps an external namespace or internal alias). 

Second we need the List URL which is fairly straightforward from the workflow properties, something like this:
This provides the site collection and subsite relative URL  “sites/mysite/doclibname”

However this still is not enough to product something that can be clicked by a uers and display their document metadata….we need MORE!

Next we need to grab the remaining url information to pick the proper display form, code would be as follows:
 Finally, tack on a “?ID=” and the workflowProperties.ItemId

So how does this look in the end?  This would get you a document display page in a given workflow….happy SharePointing!
LocalWebUrl() & "/" & workflowProperties.ListUrl & workflowProperties.List.Forms(PAGETYPE.PAGE_DISPLAYFORM).ServerRelativeUrl & "?ID=" & workflowProperties.ItemId


User Alerts on Site Collection causes error

October 9, 2009

So I was trying to manage user alerts that were getting bounced due to ex-employees no longer having valid mailboxes.  I go into the Site Collection and get a wonderfully straight forward and insightful message:

Object reference not set to an instance of an object.   at Microsoft.SharePoint.ApplicationPages.SiteSubsPage.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Now as with all SharePoint errors I immediately go to Google…and find that there are Hot Fix updates for August 2009

WSS 3.0 http://support.microsoft.com/kb/973410/  

MOSS 2007… http://support.microsoft.com/kb/973409/

Included in the WSS 3.0 Hot Fix is “After you install Office SharePoint Server 2007 Service Pack 2, you receive the following error message when you try to visit the SiteSubs.aspx”.   So apparently my quest to Service Pack my SharePoint server broke something that needs another fix.  I will be running these on my development server and then install on my production box…will report back if the issue is resolved.

UPDATE: New SharePoint Moss 2007 version on development server is  Verified that the User Alerts page now works.  Will be installing on my production server soon.


Welcome to my site…

October 7, 2009

I have been meaning to write a blog for a long time, but never got around to it.  The main goal of this site will be to share my findings about SharePoint 2007 and the daily trials and tribulations I encounter with this product.  It is a blessing and a curse to run a SharePoint environment…I will do my best to share insight and findings that I think are valuable to the hoi polloi!

I have found many solutions to problems that have eluded me in the past using other blogs on the interweb…I hope my findings will prove to be just as valuable to the community at large.