Highlighted

How to get hold of eventType in workflow class?

Avatar

Avatar

srig786

Avatar

srig786

srig786

05-03-2018

Hi,

I am Sri. I have created two workflow events (Node created and Node modified) using workflow launcher. I would like to know which event got triggered ?. Do we have a method to read eventType using arguments available in the execute method or please let me know if there is another way to get hold of event type ?

  @Override

  public void execute(WorkItem arg0, WorkflowSession arg1, MetaDataMap arg2)

  throws WorkflowException {

          //how to get hold of event type that is triggered ?

  }

Replies

Highlighted

Avatar

Avatar

navinkaushal

Avatar

navinkaushal

navinkaushal

05-03-2018

Hi srig786,

The event you are talking about is not a part of Workflows. Its part of Node and JCR Event Observation Class. What you may need to do is:

1. Create a JCR Event Observer/Handler Service (example is here Creating an AEM JCR Event Listener using a Maven Archetype 12 Project )

2. Add both the observations in that service.

3. Use that service to observe while executing your workflow model.

Hope this helps!

Regards,

Navin

Highlighted

Avatar

Avatar

srig786

Avatar

srig786

srig786

06-03-2018

Thanks Navin. I would give it a try and get back to you.

Highlighted

Avatar

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

910

Correct Answer

1.0K

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

910

Correct Answer

1.0K
Jörg_Hoh
Employee

06-03-2018

In the workflow itself it is not immediately obvious why it has been triggered (by which condition of the workflow launcher). But that shouldn't matter at all. If you need to know that it would be the easiest if you trigger a different workflow; and then of course you can reuse workflow steps, so the overhead of this is quite low.

Jörg