Posts

Showing posts from February, 2012

Sharepoint 2010 - Advanced Settings for Document library in SharePoint 2010 using PowerShell

Image
In this article we will be seeing how to change the Advanced Settings for Document library in SharePoint 2010 using PowerShell and c#. Go to Document Library => Library Settings => General Settings =>Advanced Settings. Using C#: using  (SPSite site = new SPSite("http://serverName:1111/"))             {                 using (SPWeb web = site.RootWeb)                 {                     SPList docLibrary=web.Lists["Doc Library"];                      // Change the advanced settings                      // Update the changes                     docLibrary.Update();                 }             } Using PowerShell $site=Get-SPSite "http://serverName:1111/" $web=$site.RootWeb $docLibrary =$web.Lists["Doc Library"] # Change the advanced settings $docLibrary.Update() Content Types: C#: docLibrary.ContentTypesEnabled = false; PowerShell: $docLibrary.ContentTypesEnabled = $false Opening Documents in the Browser: C#: // Open in the clien

Sharepoint 2010 - Filter Web Part with QueryString: an issue?

Image
In Sharepoint 2010, when you want to filter a List Web Part with a Form Web Part, you find the simple way with querystring and XSLT query. List web part shows 5 results per page, and we have 3 pages (so 15 items). I search for title and I see 3 results in the first page, but I see link for the other 3 pages. And navigating the other page, I see one more result in second page and the third is empty...! Filter shows results for the page 1 (3 items), for the page 2 (1 item) and for the page 3 (0 items), but divided in 3 pages. It seems filter "hides" results not matching from view, keeping pages. I decided to use filter with querystring used by Sharepoint when you filter columns. So the address bar shows this: You can use javascript to retrieve value for FilterFieldN (the column name to filter, internal name!) and FilterValueN (value to use in filter). In this way, List Web Part filtered is in the right view: if I filter my 15 items, I found olny 3, but

Sharepoint 2010 - Associate Workflow to List with Power Shell

I create a new Workflow Template (globally reusable) in root site and I associate it to a List in a Site Template. But I need to update each sub site (created from my Site Template) with the new Workflow. I use PowerShell, to cycle each subsite and associate WF to content type list. This is command I used: [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") $site=Get-SPSite "http://sharepoint_root_site" foreach($web in $site.AllWebs){    $list=$web.Lists["MyList"]    $taskList=$web.Lists["Workflow Tasks"]    $historyList=$web.Lists["Workflow History"]    $ct=$list.ContentTypes["MyContenType"]    $culture=New-Object System.Globalization.CultureInfo("en-US")    $wfTemplate=$web.WorkflowTemplates.GetTemplateByName("wfTemplate", $culture)    $associationWF=[Microsoft.SharePoint.Workflow.SPWorkflowAssociation]::CreateListContentTypeAssociation($wfTemplate, "MyWFInSubSi

Sharepoint 2010 - Filter List/Library Web Part with XSLT and Content Editor WP

Image
I created a simple Filter Web Part with a Content Editor WP and simple XLST to filter List/Library with the LIKE feature. It works for lists and libraries (in libraries not for Name field). Create a page with Library Web Part to filter. Then add a Content Editor Web Part end edit HTML Source. In HMTL, add an input textbox and two buttons, for reset filter and for submit filter. Add some script as shown below: <script type="text/javascript"> //this script get query string from URL function querySt(ji){   hu = window.location.search.substring(1);   gy = hu.split("&");   for (i=0;i<gy.length;i++){     ft = gy[i].split("=");     if (ft[0] == ji){       return ft[1];     }   } } //this script set value read from query string in input field function setValues(){    if(querySt('qtitle') != null && querySt('qtitle') != "")    {      document.getElementById('query_title').value = query