Complete Workflow Programatically | AEM 6.5
Hi All,
I have a workflow which activates the page based on a condition and there are some additional process also available apart from activation. In the below code, I am replicating the asset , if the drop down selection is approve(I am using dialog in the dynamic participant step). Now how can I complete the workflow programatically. I cannot do this using OR split options as the split is not suitable for my use case.
String payLoad = workItem.getWorkflowData().getPayload().toString();
List<HistoryItem> history = workflowSession.getHistory(workItem.getWorkflow());
if (!history.isEmpty()) {
HistoryItem last = history.get(history.size() - 1);
String action = last.getWorkItem().getMetaDataMap().get("revieweroptions", StringUtils.EMPTY);
if (StringUtils.equalsIgnoreCase("approve", action)) {
try {
replicator.replicate(workflowSession.adaptTo(Session.class), ReplicationActionType.ACTIVATE, payLoad);
} catch (ReplicationException e) {
logger.error("Unable to replicate the asset {}", payLoad);
}
}
if(StringUtils.equalsIgnoreCase("reject", action)) {
// Reject and Send an email
}
