Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmedcraft/879f4b782bec17de5e4f9376532ff458 to your computer and use it in GitHub Desktop.
Save pmedcraft/879f4b782bec17de5e4f9376532ff458 to your computer and use it in GitHub Desktop.
Adding a list of SDL Web (Tridion) components to Workflow using the SDL Web Core Service in Java
protected void doWorkflow(List<IdentifiableObjectData> updatedComponents) throws Exception {
if (updatedComponents.isEmpty())
return;
try {
// Build the array of components
ArrayOfstring arrayOfComponents = new ArrayOfstring();
for (final IdentifiableObjectData component : updatedComponents) {
arrayOfComponents.getString().add(component.getId().getValue());
}
// Start the bundle workflow activity
StartWorkflowInstructionData startWorkflowInstructionData = new StartWorkflowInstructionData();
// Provide a process title
ObjectFactory factory = new ObjectFactory();
startWorkflowInstructionData.setProcessInstanceTitle(
factory.createStartWorkflowInstructionDataProcessInstanceTitle("Workflow instance created by the Updater Script"));
ProcessInstanceData process = Tridion.INSTANCE.getService()
.startWorkflow(publication.getId(), startWorkflowInstructionData, readBackOptions);
// Add components to workflow
Tridion.INSTANCE.getService().addToWorkflow(arrayOfComponents,
process.getActivities().getValue().getActivityData().get(0).getId().getValue(), readBackOptions);
log.info("Components added to workflow successfully!");
}
catch(Exception e) {
log.error("Exception adding components to Workflow", e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment