3

How do you start a workflow on a bundle in the Event System in Tridion 2013 SP1?

Which DLL's do I need to refer to do so?

I have created a bundle ("tcm:26-135-8192") in Tridion and I have associated a Bundle Schema with it which has a workflow.

Bundle bundle = (Bundle)item.Session.GetObject("tcm:26-135-8192");
bundle.AddItem(item); 
bundle.Save();

StartWorkflowInstruction instruction = new StartWorkflowInstruction(item.Session);  

instruction.Subjects.Add(bundle);  

ProcessInstance result = bundle.ContextRepository.StartWorkflow(instruction);

My requirement is to add items to this bundle through event system and start the workflow on this. But i am getting a Error on bundle.Save(); which says "Item is shared".

Any suggestions?

This is what I am getting in Event Viewer . I have created this Bundle in publication 18 and I am trying to add one item in publication 26. Should i be creating this bundle in piublication 18 as well.

The item is shared.

Component: Tridion.ContentManager Errorcode: 0 User: NT AUTHORITY\NETWORK SERVICE

StackTrace Information Details: at Tridion.ContentManager.ContentManagement.RepositoryLocalObject.OnSaving(SaveEventArgs eventArgs) at Tridion.ContentManager.ContentManagement.OrganizationalItem.OnSaving(SaveEventArgs eventArgs) at Tridion.ContentManager.ContentManagement.VirtualFolder.OnSaving(SaveEventArgs eventArgs) at Tridion.ContentManager.ContentManagement.Bundle.OnSaving(SaveEventArgs eventArgs) at Tridion.ContentManager.IdentifiableObject.Save(SaveEventArgs eventArgs) at Tridion.ContentManager.IdentifiableObject.Save() at Tridion.ContentManager.ContentManagement.VirtualFolder.Save() at MetLife.ADD.Tridion.Eventing.PageUnPublishWorkFlow.AddItemToUnPublishBundle(RepositoryLocalObject item) at MetLife.ADD.Tridion.Eventing.PageUnPublishWorkFlow.PageUnPublishWorkFlowChange(Page subject, UnPublishEventArgs args, EventPhases phase) at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Delegate.DynamicInvokeImpl(Object[] args) at Tridion.ContentManager.Extensibility.EventSubscription.b__0(AsynchronousEventWorkItem workItem) at Tridion.ContentManager.StaThreadPool`1.StaThread.DoWork()

3
  • Can you share the entire stack trace? Also did you confirm if the bundle is not shared/localized in publication: 26 as the error says (items cannot be added/removed from a shared/localized bundle)?
    – Likhan
    Commented Feb 26, 2014 at 6:39
  • I have added the event viewer trace. Commented Feb 26, 2014 at 7:13
  • As I already mentioned in my earlier comment that it is not possible to add/remove items to/from a bundle in shared/localized context. Ideally you should create the bundle at the lowest level in your blueprint where all of the items you want to add are available. Shared/localized items can be added to bundle.
    – Likhan
    Commented Feb 26, 2014 at 7:37

2 Answers 2

4

Use the TOM.NET API to make certain Workflow-related events in Content Manager trigger a piece of custom code you write. You can subscribe to a number of moments before, during and after a specific event.

Events related to Workflow are in the Tridion.ContentManager.Extensibility.Events namespace.

Refer to the following existing questions for more information:

2

It is not possible to add/remove items to/from a bundle in shared/localized context. Ideally you should create the bundle at the lowest level in your blueprint where all of the items you want to add are available. Shared/localized items can be added to bundle. Then start workflow on that bundle.

StartWorkflowInstruction instruction = new StartWorkflowInstruction(session);
instruction.ProcessDefinition = myProcessDefinition; // Optional, otherwise it is going to use the configured task process of the bundle.ContextRepository
instruction.Subjects.Add(bundle);
ProcessInstance result = bundle.ContextRepository.StartWorkflow(instruction);
1
  • I got it working by creating the Bundle at lowest level. I am able to trigger the Workflow associated to the Bundle and items added to this bundle. I have another question here . My actual requirement was on un-publish , I need to start the Workflow and after completion of workflow I need to unpublish it. Do I need to Stop the un-publish in Event System before starting the Workflow ? Commented Feb 26, 2014 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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