I have a problem with a workflow automatic initialization (and I have banged my head against the wall for last 8hours with this and came up with no solution).

What I want to achieve is a SPD workflow to start running when user selects "Publish a Major Version" on a document, but I cannot find any kind of attribute in my created workflow in Sharepoint designer to do this task. In the workflow header screen in SPD I have Start options to "start manually", "start on change" and "start on new item" but no other attribute even to begin with. To my understanding there should be atleast gray box that says "start on approval/publish".

I've also read these "answers" but for me it doesn't do much, I don't understand where these properties lie. So is there a way to make your workflow to start when user is asking for "Publish a Major Version" via editing some of the workflows files .xml etc. or what have I done wrong in this case?

My workflow is of a type "list workflow" associated with a document library.

  • The answer "doesn't do much" ?? What does that mean? If you correctly set your workflow to be the default Content Approval Workflow, does that not meet your requirement? – Paul Schaeflein Jul 4 '14 at 19:01
  • @PaulSchaeflein Ok, so how do I set my workflow as a default for my document library? I just don't get it.. – Han Soalone Jul 4 '14 at 19:08
  • Associate the workflow with the library as normal. Then, update the properties as shown by Ali here: sharepoint.stackexchange.com/questions/63131/… – Paul Schaeflein Jul 4 '14 at 19:10
  • @PaulSchaeflein But where can I do that? I'm propably just stupid or tired but for the love I cannot find such properties to begin with.. – Han Soalone Jul 4 '14 at 20:19
  • The page that you link as answers has sample code. – Paul Schaeflein Jul 5 '14 at 15:24

First your Workflow must be enable to allow "start by a major checkin". Just Edit the .wfconfig.xml file via SharePoint Designer and add the attribute: AllowStartOnMajorCheckin="true" See more details here.

You're are able to do the same using SharePoint Objects using C# or PowerShell.

SPWorkflowTemplate template = web.WorkflowTemplates.GetTemplateByBaseID(new       Guid("00000000-0000-0000-0000-00000000")); 
template.AllowDefaultContentApproval = false; 

Second, your List must be associated to the Workflow con content approval. Besides, if you are using a List Workflow (no reusable) you must be do that by PowerShell (or C#, maybe JavaScript either).

The next sample is using PowerShell ISE

if ( (Get-PSSnapin -Name microsoft.sharepoint.powershell -ErrorAction      SilentlyContinue) -eq $null ) {
    Add-PSSnapin "microsoft.sharepoint.powershell"

## Input parameters
$workflowId = "00000000-0000-0000-0000-00000000"
$SiteCollectionUrl = "http://siteUrl"

## Main
$web = Get-SPWeb $SiteCollectionUrl
$list = $web.Lists["LibraryName"]
$list.DefaultApprovalWorkflowId = $workflowId
$list.DefaultContentApprovalWorkflowId = $workflowId


Remember WorkflowID must be the parent template Workflow GUID for a particular instance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.