How to trigger a workflow process programmatically? | Community
Skip to main content
Dinu_Arya
Level 6
May 4, 2016
Solved

How to trigger a workflow process programmatically?

  • May 4, 2016
  • 3 replies
  • 4437 views

Hi Team,

I have written a workflow process (com.mycompany.workflow.MyWorkflowProcess) by implementing com.day.cq.workflow.exec.WorkflowProcess. I have to trigger this workflow process programmatically? The only input I got is the workflow process (i.e. com.mycompany.workflow.MyWorkflowProcess) not even the model of the workflow in which it is used.

My requirement is -

  1. Author will select the workflow from the drop-down (which is as same as the Process drop-down in the workflow Process Step)
  2. From the drop-down I will get the symbolic name of the process like com.mycompany.workflow.MyWorkflowProcess.
  3. I have to trigger this workflow programmatically.

Please help me in this.

Thanks,

AryA.

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 smacdonald2008

There are only 2 methods (not counting the Deprecated one)  exposed in the WorkFlowSession Class that starts a workflow:

WorkflowstartWorkflow(WorkflowModel model, WorkflowData data)
           Start a new Workflow instance with the given WorkflowModel and WorkflowData.
WorkflowstartWorkflow(WorkflowModel model, WorkflowData data, Dictionary<String,String> metaData)
           Deprecated. It's recommended to use #startWorkflow(WorkflowModel, WorkflowData, Map instead.
WorkflowstartWorkflow(WorkflowModel model, WorkflowData data, Map<String,Object> metaData)
           Start a new Workflow instance with the given WorkflowModel, WorkflowData and meta data.

Therefore you need a WorkflowModel and data,

In your use case - you need these as input - else it will not work.

3 replies

Dinu_Arya
Dinu_AryaAuthor
Level 6
May 4, 2016
  Ya. I have seen that article. In that they are invoking the OSGi service and passed the model as input then started the workflow using the model path.  But in my case, I have to trigger the workflow directly with the input, com.my company.workflow. MyWorkflowProcess which implements WorkflowProcess. Any idea?
smacdonald2008
Level 10
May 4, 2016
PLACEHOLDER
smacdonald2008
smacdonald2008Accepted solution
Level 10
May 4, 2016

There are only 2 methods (not counting the Deprecated one)  exposed in the WorkFlowSession Class that starts a workflow:

WorkflowstartWorkflow(WorkflowModel model, WorkflowData data)
           Start a new Workflow instance with the given WorkflowModel and WorkflowData.
WorkflowstartWorkflow(WorkflowModel model, WorkflowData data, Dictionary<String,String> metaData)
           Deprecated. It's recommended to use #startWorkflow(WorkflowModel, WorkflowData, Map instead.
WorkflowstartWorkflow(WorkflowModel model, WorkflowData data, Map<String,Object> metaData)
           Start a new Workflow instance with the given WorkflowModel, WorkflowData and meta data.

Therefore you need a WorkflowModel and data,

In your use case - you need these as input - else it will not work.