Expand my Community achievements bar.

SOLVED

Workflow -Custom Process Step Is not populated in process step dropdown

Avatar

Level 4

Hi Team,

I have created a custom process step as per the AEM 6.2 documentation but still the xustom process step is not getting populated in process step dropdown.

Below is the custom process step which i was trying-

 

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;
import com.adobe.granite.workflow.metadata.MetaDataMap;
 
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
 
import org.osgi.framework.Constants;
 
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
 
/**
 * Sample workflow process that sets an <code>approve</code> property to the payload based on the process argument value.
 */
@Component
@Service
public class CustomProcess implements WorkflowProcess {
 
    @Property(value = "An example workflow process implementation.")
    static final String DESCRIPTION = Constants.SERVICE_DESCRIPTION;
    @Property(value = "Adobe")
    static final String VENDOR = Constants.SERVICE_VENDOR;
    @Property(value = "My Sample Workflow Process")
    static final String LABEL="process.label";
 
 
    private static final String TYPE_JCR_PATH = "JCR_PATH";
 
    public void execute(WorkItem item, WorkflowSession session, MetaDataMap args) throws WorkflowException {
        WorkflowData workflowData = item.getWorkflowData();
        if (workflowData.getPayloadType().equals(TYPE_JCR_PATH)) {
            String path = workflowData.getPayload().toString() + "/jcr:content";
            try {
                Session jcrSession = session.adaptTo(Session.class);
                Node node = (Node) jcrSession.getItem(path);
                if (node != null) {
                    node.setProperty("approved", readArgument(args));
                    jcrSession.save();
                }
            } catch (RepositoryException e) {
                throw new WorkflowException(e.getMessage(), e);
            }
        }
    }
 
    private boolean readArgument(MetaDataMap args) {
        String argument = args.get("PROCESS_ARGS", "false");
        return argument.equalsIgnoreCase("true");
    }
}

Can someone let me know if there is any change in AEM 6.2.

1 Accepted Solution

Avatar

Correct answer by
Level 9

Hi Ankur,

At high level looks good to me. Start the bootstrap sample provided from acs.

https://github.com/Adobe-Consulting-Services/acs-aem-samples/blob/master/bundle/src/main/java/com/ad...

Thanks,

View solution in original post

1 Reply

Avatar

Correct answer by
Level 9

Hi Ankur,

At high level looks good to me. Start the bootstrap sample provided from acs.

https://github.com/Adobe-Consulting-Services/acs-aem-samples/blob/master/bundle/src/main/java/com/ad...

Thanks,