starting a workflow instance

Vote:
 

I am trying to start a specific workflow instance defined using the default episerver workflow .I tried he code bellow  and i get an error:

Starting of instance was cancelled by event handler to InstanceStarting, reason: No valid page is selected for approval workflow” exception

Can you tell if I'm missing something or maybe this is not the proper aproach to do this

EPiServer.WorkflowFoundation.StorageProviders.ObjectStoreStorageProvider Storage = new ObjectStoreStorageProvider();

                IList<WorkflowDefinition> instances = Storage.LoadDefinitions();

                foreach (WorkflowDefinition def in instances)

                {

                    if (def.PageRoot.ID == CurrentPage.PageLink.ID)

                    {

EPiServer.WorkflowFoundation.WorkflowSystem.InstanceHandler.StartInstance(def.DefinitionId, def.StartParameters ,      CurrentPage.PageLink, EPiServer.Security.AccessLevel.Read);

                    }

                }

 

Thanks

#34286
Nov 01, 2009 19:34
Vote:
 

Did you find a solution for this? I'm experiencing the same problem.

#45681
Nov 12, 2010 14:41
Vote:
 

To pass in which page the  approval workflow  should operate on you should do something like:

 Dictionary<string, object> args = new Dictionary<string, object>();
            args.Add("PageArgs", new WorkflowPageEventArgs(WorkflowPageEvent.None, CurrentPage.PageLink, PageReference.EmptyReference, null, null);

 Dictionary<string, object> args = new Dictionary<string, object>();            

args.Add("PageArgs", new WorkflowPageEventArgs(WorkflowPageEvent.None, CurrentPage.PageLink, PageReference.EmptyReference, null, null);

EPiServer.WorkflowFoundation.WorkflowSystem.InstanceHandler.StartInstance(def.DefinitionId, args , CurrentPage.PageLink, EPiServer.Security.AccessLevel.Read);

#45845
Nov 19, 2010 12:40
Vote:
 

I have a client that is getting the same error message when starting any of the 4 supplied workflows in EPiServer 6 - any information regarding how to overcome this problem would be warmly received

#50668
May 09, 2011 16:42
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.