Skip to content

How to make a link that will open Sharepoint Workspace or SkyDrive Pro

July 25, 2013

In my previous post I have been discussing a web part that should create a new library.

The next thing we were asked was to create a link that will open Sharepoint WorkSpace or SkydrivePro

Just like this

 

 

It turned out that you need provide a very weird encoded link

Here is a link we have produced in our webpart

 

grvopen://http_58_47_47sp2010_47sites_47onenote_47test/5f594410_451d8c_454d0c_45af05_4500f60a0e1bea/101?OPENLIST

 

Grvopen stands for Groove (that was later renamed to Sharepoint WorkSpace and later to SkyDrive Pro)

The piece of code that does encoding is taken from Tatham Oddie

https://gist.github.com/tathamoddie/5858129

And is posted to his github

http://blog.tatham.oddie.com.au/

 

Here is a full code

 

// based on https://gist.github.com/tathamoddie/5858129
static string BuildGrooveUri(SPDocumentLibrary lib)
{
   
var libUrl  = SPUtility.ConcatUrls(lib.ParentWeb.Url, lib.RootFolder.Url);
   
const string grooveOpenUriTemplate = "grvopen://{0}/{1}/{2}?OPENLIST";
   
var uri = string.Format(
        grooveOpenUriTemplate,
        Encode(libUrl),
        Encode(lib.ID.ToString()),
        (
int)lib.BaseTemplate);
   
return uri;
}
 
static string Encode(string plain)
{
   
return plain
        .ToCharArray()
        .Select(c =>
char.IsLetterOrDigit(c) ? c.ToString() : "_" + ((int)c).ToString())
        .Aggregate(
"", (s, c) => s + c);
}

Enjoy!

Advertisements
2 Comments
  1. @RikardStrand permalink

    Is it possible to convert this to powershell code ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: