Monday 10 September 2018

AEM Workflows And Launchers - A powerful tool to automate process.

In this era of automation, the demand is to enforce the process to happen without manual intervention. In order to achieve this workflows and launchers play a major role in achieving it.

Workflows
Workflow allows the developers to automate the steps to be carried out. It allow us to manipulate the jcr resources on the go. AEM provides many inbuilt workflows, but a developer also has the flexibility to create a custom workflow.

The workflow dashboard can be accessed from the below url.
http://localhost:4502/libs/cq/workflow/content/console.html

The state of the workflow can be traced from the Archive tab from the workflow console. Worklow exhibits the following state.

  • Running
  • Completed
  • Suspended
  • Aborted
  • Stale
Launchers
In order to fire the workflows automatically, launcher is the tool that can be of help. The launchers fire the workflow based on the event type, node type, path, etc. For example:: A new property can be set to the page created. In the launcher dialog we have the configuration to select the workflow to associate with it.

Workflow Sessions
The workflow sessions can be very useful to process the payloads. Below code can help the developers fetch the session in a workflow.
session = workflowSession.adaptTo(javax.jcr.Session.class);
session = workflowSession.getSession();
The syntax code snippet to create a custom workflow process is discussed in the below blog.
http://anshumankumaraem.blogspot.com/2017/11/whats-new-in-aem-63.html

What is a payload in workflow ??
This is the resource on which the workflow is subjected. Ex: A Page.
Below code snippet can help fetch the payload in the workflow.
WorkflowData workflowData = workItem.getWorkflowData();
String payLoadPath = (String) workflowData.getPayload();

extraClientlibs Usage

The purpose of property "extraClientlibs" is to selectively load client library for a dialog. This prevents the unnecessary load o...