Expand my Community achievements bar.

SOLVED

How to trigger a workflow process programmatically?

Avatar

Level 7

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.

1 Accepted Solution

Avatar

Correct answer by
Level 10

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.

View solution in original post

3 Replies

Avatar

Level 7
  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?

Avatar

Correct answer by
Level 10

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.