Albert Jan Schot
 

Deploying SPD Workflows with PowerShell

27

Sep

With the new SharePoint Designer creating reusable workflows has become fairly easy, however deploying them seems to be a bit harder, lets say you create a reusable workflow that you use globally  on all your content types, it seems it still has to be deployed to each list you use it in. So saying you would have 50 lists with that content type forces you to add that workflow 50 times.

For that reason the following PowerShell example might come in handy, it allows you to search a workflow you create with SharePoint designer, and add that to your SPList (ofcourse you can also use an SPWeb or other object that supports the SPWorkflowAssociation to bind it to).

 

  1: #Clear old output
  2: clear; 
  3: 
  4: #Write some header
  5: Write-Host -ForegroundColor Green "Publish Workflow Test"; 
  6: 
  7: #Load required dll
  8: [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Workflow") 
  9: 
 10: #Load Snappin 
 11: $snapin="Microsoft.SharePoint.PowerShell"
 12: if (get-pssnapin $snapin -ea "silentlycontinue") {}
 13: else {
 14:       if (get-pssnapin $snapin -registered -ea "silentlycontinue") {
 15:             Add-PSSnapin $snapin
 16:             write-host -f Green "PSsnapin $snapin is loaded"
 17:       }
 18:       else {
 19:             write-host -f Red "PSSnapin $snapin not found" 
 20:       }
 21: }
 22: 
 23: #Get some required objects
 24: $web = Get-SPWeb -Identity "http://portal.sp2010.dev";
 25: $rootweb = $web.Site.RootWeb; 
 26: $wfList = $web.Lists["Pages"];
 27: $wfTaskList = $web.Lists["Workflow Tasks"];
 28: $wfHistoryList = $web.Lists["Workflow Tasks"];
 29: 
 30: #Get Workflow
 31: foreach($workflow in $rootweb.WorkflowTemplates) 
 32: {
 33:       #User $workflow.Name to mach on 
 34:       Write-Host -ForegroundColor Yellow " Found a workflow: " $workflow.Name 
 35:       
 36:       if($workflow.Name -eq "TestAppie") 
 37:       {
 38:             $setflow = $workflow; 
 39:       }
 40: }
 41: 
 42: Write-Host -ForegroundColor Green "Found the workflow: " $setflow.Name; 
 43: 
 44: $association = [Microsoft.SharePoint.Workflow.SPWorkflowAssociation]::CreateListContentTypeAssociation($setflow, "Test", $wfTask, $wfHistory);
 45: 
 46: $list.WorkflowAssociations.Add($association); 
 47: $list.Update();
 48: 

Albert-Jan Schot schreef

Comments (0)

Albert-Jan Schot

Editing pages with the SharePoint Designer 2010

24

Sep

So always nice to update a few minor things on a pagelayout using SharePoint Designer, especially if it has to be done quick, however this week I spend the first hour cursing why SPD wouldn't allow me to edit my pagelayout. Seems to be that opening it, checking it out isn’t enough. You have to press the advanced button…

Opening a pagelayout took a few minutes to get, due to the fact that in SPD2010 you have to click the ‘edit file’ after opening the file. Once you are in editing mode all the html in code view is a bit yellow though, and not editable. To get it editable you have to click the Advanced mode button, after doing so you will be able to edit your page as like. However once you clicked it, it will grey out..

 

image

Albert-Jan Schot schreef

Comments (0)

Albert-Jan Schot

SharePoint 2010 Search Page and the UIVersionedContent control

27

May

The default SharePoint 2010 Search center has a nice predefined results page for you, containing a nice set of WebParts. However if you create a Search Center you can see that returning to your site is a pretty hard task. So today someone asked me if we could make a page-layout exactly like the default search results page, allowing them to create resultpages anywhere in their portal. That being said, the only thing I had was the SharePoint Designer, luckily for me it was a 2010 project :).

So first thing I did was copying the default WelcomeLinks.aspx pagelayout, since that page has no left sidebar, next thing was to simply copy the table structure to the page and tweaking it a bit. However after checking it in, and publishing it, I got stuck with an unknown error. After some debugging my logs shows the error:

Exception No parameterless constructor defined for this object.

After some more debugging it seems that one of the WebParts on the default search page got an invalid property, so after deleting all the WebParts, leaving me with an empty page with nothing but some WebPartZones I checked it in, and published it again. Just to bring me the next error:

Unknown server tag 'SharePoint:UIVersionedContent'.

For some reason the WelcomeLinks.aspx is allowed to use the UIVersionedContent, but as soon as you ‘customize’ it, you aren’t anymore. Adding the next line will do the trick:

<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

After that you’re good to go, and you will have a nice SearchResults look-a-like pagelayout.

Result:

SearchResults.zip (2.08 KB)

Albert-Jan Schot schreef

Comments (0)

Albert-Jan Schot
Page 1 of 1 in the SharePointDesigner category