Do we have an example of OR split in workflow using a process step instead of an ecma script ? | Community
Skip to main content
Level 4
November 16, 2023
Solved

Do we have an example of OR split in workflow using a process step instead of an ecma script ?

  • November 16, 2023
  • 2 replies
  • 1225 views

Do we have an example of OR split in workflow using a process step instead of an ecma script ?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

Hi @vishwanath881 
Unfortunately , I am not able to locate the dependency, I thought It would be part of uber jar.

 

However, I have also not tried it by myself.

 

you can try different approach

import com.adobe.granite.workflow.WorkflowException; import com.adobe.granite.workflow.WorkflowSession; import com.adobe.granite.workflow.exec.WorkItem; import com.adobe.granite.workflow.exec.WorkflowData; import com.adobe.granite.workflow.exec.WorkflowProcess; public class MyCustomProcessStep implements WorkflowProcess { @Override public void execute(WorkItem workItem, WorkflowSession workflowSession, WorkflowData workflowData) throws WorkflowException { // Your OR split logic here String condition1 = "your condition 1"; // Replace with your actual conditions String condition2 = "your condition 2"; if (condition1.equals("true") || condition2.equals("true")) { // Route the workflow to the appropriate path based on the OR split conditions workflowSession.complete(workItem, "YOUR_NEXT_WORKFLOW_STEP"); } else { // Handle the case when neither condition is met workflowSession.complete(workItem, "ANOTHER_NEXT_WORKFLOW_STEP"); } } }

2 replies

arunpatidar
Community Advisor
Community Advisor
November 16, 2023
package com.example.workflow; import com.adobe.granite.workflow.WorkflowException; import com.adobe.granite.workflow.WorkflowSession; import com.adobe.granite.workflow.exec.WorkItem; import com.adobe.granite.workflow.split.SplitResult; import com.adobe.granite.workflow.split.impl.AbstractSplitter; import org.osgi.service.component.annotations.Component; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Component(service = AbstractSplitter.class, immediate = true) public class OrSplitter extends AbstractSplitter { private static final Logger LOGGER = LoggerFactory.getLogger(OrSplitter.class); @9944223 public SplitResult doSplit(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException { // Retrieve the workflow variable "conditionVariable" String conditionVariable = (String) workItem.getWorkflowData().getMetaDataMap().get("conditionVariable"); // Check the condition boolean conditionMet = "someValue".equals(conditionVariable); if (conditionMet) { LOGGER.info("Condition met. Proceeding along path A."); return new SplitResult("A"); } else { LOGGER.info("Condition not met. Proceeding along path B."); return new SplitResult("B"); } } }
Arun Patidar
Level 4
November 16, 2023

Thanks Arun, let me try and get back.

kautuk_sahni
Community Manager
Community Manager
November 20, 2023

@vishwanath881 Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni