SharePoint 2010 Take list or site offline to SharePoint Workspace 2010 with javascript

Taking SharePoint lists, libraries or site offline, might be one of the features your customer will ask sooner or later. Normally you have the ECB menu, where you can find the “synchronize with SharePoint Workspace” Button. But maybe you want to create your own button or link or wrap some more logic to this functionality.  In order to do so, i did some researching and came back with a solution, which i would like to share.

In order to achieve this, you’ll have to use a special ActiveXObject which is called Groove.SiteClientActiveX. I found two code snippets and tested them. First one to take offline a whole site and the second one to take a special list or library offline. You need the site url and optionally the list or library id. But look at the code and you will see how it works.

How to take a site offline:



<script type="text/javascript">

function syncSiteSPW(siteUrl)
{
var offlineClientScope_Site = 1;
var offlineClientScope_ListOrLibrary = 2;
var offlineClientScope_Folder = 3

var a = new ActiveXObject('Groove.SiteClientActiveX');
if(a.IsOfflineAllowed(
offlineClientScope_Site,
100,
100,
1001))
a.TakeOffline(
offlineClientScope_Site,
1,
siteUrl,
1,
1,
'',
'');
else
alert('Site cannot be taken offline.');
}

</script>


 

How to take a list or library offline:



<script type="text/javascript">

function syncListSPW(siteUrl, listId)
{
var offlineClientScope_Site = 1;
var offlineClientScope_ListOrLibrary = 2;
var offlineClientScope_Folder = 3

var a = new ActiveXObject('Groove.SiteClientActiveX');
if(a.IsOfflineAllowed(
offlineClientScope_ListOrLibrary,
100,
100,
100))
a.TakeOffline(
offlineClientScope_ListOrLibrary,
1,
siteUrl,
1,
1,
listId,
'');
else
alert('List cannot be taken offline.');
}

</script>


Just provide a link which calls one of the functions and it opens the SharePoint Workspace 2010.

..:: I LIKE SHAREPOINT ::..

The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

Karsten Pohnke About Karsten Pohnke
He is Consultant for SharePoint Solutions for collaboration, communication and business processes. He provides his customers applications based on standard features as well as development or combining the power of several microsoft tools like Dynamics CRM. In his free time he tries to collect tipps and worthy experience in this blog.

Submit comment

Allowed HTML tags: <a href="http://google.com">google</a> <strong>bold</strong> <em>emphasized</em> <code>code</code> <blockquote>
quote
</blockquote>

Please fill in the captcha: * Time limit is exhausted. Please reload CAPTCHA.