I've read the question/answer of how to start bundle workflow by event system and I've leveraged the stuff here to create bundle and add items via core service. But, I can't quite figure out how to start workflow on a bundle. I see the StartWorkflow method in ICoreService2012. but that doesn't accept a bundle. That expects the ID of a repository and StartWorkflowInstructionData. Am I able to use StartWorkflowInstructionData to specify the bundle to start the workflow?
1 Answer
Try this:
StartWorkflowInstructionData startWorkflowInstruction = new StartWorkflowInstructionData();
startWorkflowInstruction.Assignee = new LinkToTrusteeData { IdRef = client.GetCurrentUser().Id };
startWorkflowInstruction.ActivityTitle = "A title for the activity";
startWorkflowInstruction.ProcessInstanceTitle = "A title for the process instance";
startWorkflowInstruction.Subjects = new[] { new LinkToIdentifiableObjectData { IdRef = bundle.Id } };
client.StartWorkflow("THE_URI_OF_PUBLICATION", startWorkflowInstruction, new ReadOptions());
Basically the StartWorkflowInstructionData
has an array of Subjects
, you just add your bundle to that collection.