How to start K2 Workflow from the code?

  • 21 December 2012
  • 2 replies
  • 7 views

Badge +3

Hi All,


I need to start K2 Workflow manually from the code. I am using code below and my code actually starts K2 workflow but workflow instance immediately fails with the error. The error is "DefaultLine - String was not recognized as a valid Boolean. " Looks like workflow fails on first line rule. My workflow is tested and works fine if it is started automatically from Item Updated. What is wrong with my code?


 SPWorkflow wf = null;


SPList parentList = afeafd.Project.Item.ParentList;


SPWorkflowAssociationCollection associationCollection = parentList.ContentTypes[ContentTypeName].WorkflowAssociations;


foreach (SPWorkflowAssociation association in associationCollection)


{


    wf = SPContext.Current.Site.WorkflowManager.StartWorkflow(afeafd.Project.Item, association, association.AssociationData);


}


2 replies

Badge +6

Is Business rule added to the Default Line rule?  Or simply delete the line rule and recreate it.

Thanks,

Badge +6

I dont think the code is wrong. I am sure you get the same error if you start the workflow from workspace


change the data type of the data field that was used in the line rule to Boolean.

Reply