내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

How to invoke a workflow providing data/arguments using Java API

Avatar

Level 4

Hello folks. I've followed this https://helpx.adobe.com/experience-manager/using/invoking-experience-manager-workflows-using.html and can invoke my workflow using the Java API. I'm trying to tweak this example so that I can start the workflow with MetaDataMap containing key value pairs for the steps to work with. The log message prints the key and value sets. But the steps in the workflow do not have this data. How do I pass a MetaDataMap to the workflow when starting it with the Java API?

//This is a component so it can provide or consume services @Component @Service public class InvokeWorkflowImpl implements InvokeWorkflow { @Reference private WorkflowService workflowService; @Reference private WriteService writeService; private Session session; protected final Logger log = LoggerFactory.getLogger(this.getClass()); @Override public String StartWorkflow(String workflowName, String workflowContent, MetaDataMap metaMap) { try { //Invoke the adaptTo method to create a Session ResourceResolver resourceResolver = writeService.getResolver(); session = resourceResolver.adaptTo(Session.class); //Create a workflow session WorkflowSession wfSession = workflowService.getWorkflowSession(session); // Get the workflow model WorkflowModel wfModel = wfSession.getModel(workflowName); // Get the workflow data // The first param in the newWorkflowData method is the payloadType. // Just a fancy name to let it know what type of workflow it is working with. WorkflowData wfData = wfSession.newWorkflowData("JCR_PATH", workflowContent); for(Entry<String, Object> entry: metaMap.entrySet()){ log.info("WF Args entry="+ entry.getKey()+" "+entry.getValue()); wfData.getMetaDataMap().put(entry.getKey(), entry.getValue()); }                         // also tried                            // wfSession.startWorkflow(wfModel, wfData, metaMap);
// Run the Workflow. wfSession.startWorkflow(wfModel, wfData); return workflowName +" has been successfully invoked on this content: "+workflowContent ; } catch(Exception e) { e.printStackTrace(); } return null; } }
1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Level 4

I have an answer posted here http://stackoverflow.com/questions/31594292/how-to-invoke-a-workflow-providing-data-arguments-using-... in the execute method I was trying to use the MetaDataMap parameter, but needed to use workItem.getWorkflowData().getMetaDataMap()

원본 게시물의 솔루션 보기

2 답변 개

Avatar

정확한 답변 작성자:
Level 4

I have an answer posted here http://stackoverflow.com/questions/31594292/how-to-invoke-a-workflow-providing-data-arguments-using-... in the execute method I was trying to use the MetaDataMap parameter, but needed to use workItem.getWorkflowData().getMetaDataMap()

Avatar

Level 10

That is a good next article for this series. I will make sure we get that written. In mean time - I have asked WIll (our eng member) to look at this.