Last active
March 2, 2017 21:02
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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