6

I would like to start workflow on a Bundle after creating it in the Event System. I have the following code, but the StartWorkflow method fails with "The method or operation is not implemented."

Do I need to first create some workflow items and associate it before doing start workflow?

TcmUri uri = new TcmUri(bundleFolderUri);
Bundle bundle = new Bundle(session, uri);
Schema specificBundleSchema = (Schema)session.GetObject(specificBundleSchemaUri);
bundle.MetadataSchema = specificBundleSchema;

bundle.Title = "Bundle for " + comp.Title;
bundle.Save();

bundle.AddItem(comp);
bundle.Save();

bundle.StartWorkflow();
  • Are you sure the bundle is associated to a schema with Workflow? Do you have the option to start the workflow in the UI? – Nuno Linhares Jul 3 '13 at 13:03
  • I have the option to start WF in the UI by double-clicking on the Bundle (and it shows the items in it) and then the Start Workflow button. – robrtc Jul 3 '13 at 13:20
  • Is there anything in the Tridion event log? – Andrey Marchuk Jul 3 '13 at 13:30
  • Error message in Event Viewer is, "The method or operation is not implemented. Component: Tridion.ContentManager Errorcode: 0 User: NT AUTHORITY\NETWORK SERVICE StackTrace Information Details: at Tridion.ContentManager.ContentManagement.Bundle.StartWorkflow() at EventSystemBundles.AutoCreateBundle.OnComponentSavePost(Component comp, SaveEventArgs args, EventPhases phase) in E:\Projects\EventSystem\EventSystemBundles\AutoCreateBundle.cs:line 41" and line 41 is bundle.StartWorkflow(). Is there something else I need to do before StartWorkflow? – robrtc Jul 4 '13 at 8:37
8

It's a pity - but really this method is not implemented. I advice you to use something next :

 StartWorkflowInstruction instruction = new StartWorkflowInstruction(session);
 instruction.Subjects.Add(bundle);
 ProcessInstance result = bundle.ContextRepository.StartWorkflow(instruction);

Note, that in StartWorkFlowInstruction you can specify additional information (such as ProcessDefinition). If StartWorkflowInstruction has one subject - Tridion tries to resolve it as Bundle (and in this case it will start workflow for all bundle items). Also with help of this method you can start workflow for specific list of subjects.

|improve this answer|||||

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.