You are reading the AEM 5.6 version of Creating Workflow Models.
This documentation is also available for the following versions:
CQ 5.5
Create a workflow model to define a series of steps to execute. New workflow models include Flow Start and Flow End steps that represent the beginning and end of the workflow. The model also contains an example Participant step named Step 1. The step is configured to assign a work item to the admin user. Edit or delete this step, and add steps as required.
On the Models tab, click New. The New Workflow dialog opens.
Type the title for your workflow and click OK.
The new model appears in the Models tab.
Adding a Step to a Model
Add steps to a model to represent an activity to perform. Several step components are installed with AEM. Each step performs a specific activity. When you edit a model, the available steps appear on the Components tab in Sidekick.
For information about the step components that are installed with AEM, see Workflow Steps Reference.
At run time, steps are executed in the order in which they appear in the model. After adding step components, you can drag them to a different location in the model.
On the Models tab of the Workflow console, select a workflow model and click Edit.
Drag a worklfow step component from Sidekick to the model. A checkmark icon on the component indicates a valid drop location.
Editing a Workflow Step
Configure step components to change their behavior. Step components provide properties dialogs for configuring.
Right-click a process step in the workflow model and click Edit:
Configure the step properties. For information about the properties of installed step components, see Workflow Steps Reference.
Creating a Simple Workflow
To illustrate some of the possibilities for creating a workflow, the following example creates a variation of the Publish Example workflow.
Right-click Step 1 and click Edit.
Enter Validate Content for the Title and Description.
Set the User/Group to /home/users/a/admin and click OK.
Drag an Or Split onto the workflow and position it between Validate Content and Flow End.
Right-click the Or Split step and click Edit.
For Branch 1, select Default Route. For Branch 2, ensure Default Route is not selected.
Click OK.
Drag a Participant Step component to the left-hand branch, open the properties, specify the following property values, and click OK:
Title: Cancel Publish.
User/Group: /home/users/a/admin
Drag a Process Step to the right-hand branch, open the properties, specify the following values, and click OK:
Title: Publish Page
Process: Select Active Page. This process publishes the selected page to the publisher instances.
Click Save.
Defining a Rule for an OR Split
OR splits allow you to introduce conditional processing paths into your workflow. To define an OR rule, proceed as follows:
Create the two scripts and save them in the repository, for example under /apps/myapp/workflow/scripts.
Note: the scripts must have a function check() that returns a boolean.
Edit the workflow and add the OR split to the model.
Edit the properties of one branch of the OR split.
Define the Default Route by setting the Value to true.
As Rule, set the path to the script. For example: /apps/myapp/workflow/scripts/myscript1.ecma.
Edit the properties of the other branch of the OR split.
As Rule, set the path to the other script. For example: /apps/myapp/workflow/scripts/myscript2.ecma.
Set the properties of the steps in each branch. Make sure the User/Group is set.
The following objects are available within ECMA scripts:
You can develop workflow steps that obtain the package resources and process them.The following members of the com.day.cq.workflow.collection package provide access to workflow packages:
ResourceCollection: Workflow package class.
ResourceCollectionUtil: Use to retrieve ResourceCollection objects.
ResourceCollectionManager: Creates and retreives collections. An implementation is deployed as an OSGi service.
The following example Java class demonstrates how to obtain package resources.
package com.adobe.example;
import java.util.ArrayList;
import java.util.List;
import com.day.cq.workflow.WorkflowException;
import com.day.cq.workflow.WorkflowSession;
import com.day.cq.workflow.collection.ResourceCollection;
import com.day.cq.workflow.collection.ResourceCollectionManager;
import com.day.cq.workflow.collection.ResourceCollectionUtil;
import com.day.cq.workflow.exec.WorkItem;
import com.day.cq.workflow.exec.WorkflowData;
import com.day.cq.workflow.exec.WorkflowProcess;
import com.day.cq.workflow.metadata.MetaDataMap;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.felix.scr.annotations.Reference;
import org.osgi.framework.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.jcr.Node;
import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
@Component
@Service
public class LaunchBulkActivate implements WorkflowProcess {
private static final Logger log = LoggerFactory.getLogger(LaunchBulkActivate.class);
@Property(value="Bulk Activate for Launches")
static final String PROCESS_NAME ="process.label";
@Property(value="A sample workflow process step to support Launches bulk activation of pages")
static final String SERVICE_DESCRIPTION = Constants.SERVICE_DESCRIPTION;
@Reference
private ResourceCollectionManager rcManager;
public void execute(WorkItem workItem, WorkflowSession workflowSession) throws Exception {
Session session = workflowSession.getSession();
WorkflowData data = workItem.getWorkflowData();
String path = null;
String type = data.getPayloadType();
if (type.equals(TYPE_JCR_PATH) && data.getPayload() != null) {
String payloadData = (String) data.getPayload();
if (session.itemExists(payloadData)) {
path = payloadData;
}
} else if (data.getPayload() != null && type.equals(TYPE_JCR_UUID)) {
Node node = session.getNodeByUUID((String) data.getPayload());
path = node.getPath();
}
// CUSTOMIZED CODE IF REQUIRED....
if (path != null) {
// check for resource collection
ResourceCollection rcCollection = ResourceCollectionUtil.getResourceCollection((Node)session.getItem(path), rcManager);
// get list of paths to replicate (no resource collection: size == 1
// otherwise size >= 1
List<String> paths = getPaths(path, rcCollection);
for (String aPath: paths) {
// CUSTOMIZED CODE....
}
} else {
log.warn("Cannot process because path is null for this " + "workitem: " + workItem.toString());
}
}
/**
* helper
*/
private List<String> getPaths(String path, ResourceCollection rcCollection) {
List<String> paths = new ArrayList<String>();
if (rcCollection == null) {
paths.add(path);
} else {
log.debug("ResourceCollection detected " + rcCollection.getPath());
// this is a resource collection. the collection itself is not
// replicated. only its members
try {
List<Node> members = rcCollection.list(new String[]{"cq:Page", "dam:Asset"});
for (Node member: members) {
String mPath = member.getPath();
paths.add(mPath);
}
} catch(RepositoryException re) {
log.error("Cannot build path list out of the resource collection " + rcCollection.getPath());
}
}
return paths;
}
}
Debugging and Testing Workflows
Refer to the section Debugging to start the AEM instance in debug mode.
You can display Debug messages related to workflows in the log files:
In your browser, go to the Apache Felix Console and select Configuration.
When the development is finished, set the Log Level back to Info.
Test a new workflow as follows:
Open the Workflow console; for example http://localhost:4502/libs/cq/workflow/content./console.html
In the Models tab, right-click the model and select Start.
Define the Payload and click OK.
If one of the steps is a User Step, click the Inbox tab, select the step and perform the desired action.
While running the workflow, monitor the log files.
Note
It is a good practice when debugging a workflow to test the workflow with a payload type that is different than the one for which it has been developed. For example, if you intend your workflow to deal with Assets, test it by setting a Page as payload and make sure that it does not throw errors.
Using workflows to process form submissions
Open the Websites console.
Open the page on which you want add the form.
Drag a Form component from the Components tab in the Sidekick and place it in the page.
Edit the Start of Form component that appeared in the page.
Select the desired workflow from the available options under Start Workflow.
Click OK to confirm the new form configuration.
The form is now configured to be processed by the selected workflow. When users submit the form, a new workflow instance will be created, with the data of the form submission as its payload.
Tutorial: Collecting Data Using Forms and Workflows
With AEM you can associate a workflow with forms. It enables you to build processes in which visitors will input information based on multiple forms; for example, an online registration process.
In this section you will create a two steps process to display two characteristics of the "Product of the Day". In the first step, the author will fill out the first form to define the name of the product. In the second step, the author will fill out the second form and specify the designer of the product. The result will be displayed in the Product of the Day page.
Create the Product of the Day page
To create the Product of the Day page:
Go to the Websites console.
Create the Product of the Day page below Websites/Geometrixx Outdoors Site/Enlish/Equipment with the following property values: Title: Product of the Day Template: Content Page without Sidebar
Open the new page. The two columns each contain a single paragraph with no text. Add the following text to the paragraphs:
Left-hand column: Name:
Right-hand column: Designed By:
Add a Text component from the General tab of Sidekick to each of the two columns, below the existing paragraphs.
Obtain the paragraph node names
Use CRXDE Lite to find the name of the nodes in the repository that are associated with the paragraphs that you added to the Product of the Day page.
In the node tree, expand the /content/geometrixx-outdoors/en/equipment/product-of-the-day/jcr:content/par node.
Below the par node, the colctrl nodes represent the columns on the Product of the Day page, and the col_break nodes represent the end of the columns. The left-hand column is the first colctrl node, and the right-hand column is the second colctrl node.
Note the name of the second text node after the first colctrl node. The second text node represents the empty text component that you added to the left-hand column.
Note the name of the second text node after the second colctrl node. The second text node represents the empty text component that you added to the right-hand column.
In the following graphic, the text nodes are text_cee2 and text_a233. Your node names will likely have different characters following text_.
Create the first form (form1)
To create the first form (form1):
Go to the Websites console.
Create the page form1 below Websites/Geometrixx Outdoors Site/Enlish/Equipment with the following characteristics:
Title: form1
Template: Content Page without Sidebar
Note: The location of the form pages is not important.
Open form1 and delete the 2 Columns component.
From the Form group in Sidekick, drag the Form component to the page.
Edit the Start of Form component and set the following properties on the Advanced tab to link the form to a workflow:
Action Type: Edit Workflow Controlled Resource(s)
Form Identifier:form1
Click OK.
From the Form group in Sidekick, drag the Text Field component between the Start of Form and the End of Form bars of the Form component.
Edit the Text Field component to specify the following property values:
Element Name: ./jcr:content/par/text_****/text
text_**** is the name of the node that represents the empty paragraph on the Product of the Day page. In the previous example, the node name is text_cee2.
Title: Product Name:
Click OK.
When the form is submitted, the value in this field is stored in the <payload-path>/jcr:content/par/text_0/text node.
Drag the Workflow Submit Button(s) component from Sidekick to immediately after the Text Field component. This component provides the submit button of the form.
Create the second form (form2)
To create the second form (form2):
Go to the Websites console.
Create the page form2 below Websites/Geometrixx Outdoors Site/English/Equipment with the following characteristics::
Title: form2
Template: Content Page without Sidebar
Note: The location of the form pages is not important.
Open form2 and delete the 2 Columns component.
Drag the Form component from Sidekick to the page.
Edit the Start of Form component and specify the following property values to link the form to a workflow:
Thank You Page (Form tab): {payload}.html
Action Type (Advanced tab): Edit Workflow Controlled Resource(s)
Form Identifier (Advanced tab):form2
Click OK.
Drag the Text Field component from Sidekick to between the Start of Form and the End of Form bars.
Edit the Text Field component to specify the following property values:
Element Name: ./jcr:content/par/text_****/text
text_**** is the name of the node that represents the empty paragraph on the Product of the Day page. In the previous example, the node name is text_a233.
Title: Developer Name:
Click OK.
When the form is submitted, the value in this field is stored in the <payload-path>/jcr:content/par/text_2/text node.
Drag the Workflow Submit Button(s) component from the Sidekick to immediately after the Text Field component. This component provides the submit button of the form.
Create the workflow
To create the workflow:
Go to the Workflow console.
In the Models tab, create a new workflow model with the title Product of the Day.
Edit the new workflow.
Delete Step 1.
Drag a Form Participant Step component to the workflow. Specify the following property values:
Title: Step 1
User/Group: /home/users/a/admin
Form path:/content/geometrixx-outdoors/en/equipment/form1
Add a Form Participant Step component after Step 1 and specify the following property values:
Title: Step 2
User/Group: /home/users/a/admin
Form path: /content/geometrixx-outdoors/en/equipment/form2
Save the workflow model.
Apply the workflow to the Product of the Day page
To apply the workflow to the Product of the Day page:
Open the Product of the Day page in edit mode. If the page is still open from a previous procedure, reload it.
In Sidekick, click the Workflow tab and select the Product of the Day workflow. Click Start Workflow.
Select the Step 1 item for the Product of the Day content, and click Open.
The form1 page opens.
In the Product Name box, type Abidjan Water Red, and click Next.
The form2 page opens.
In the Developer Name box, type Abidjan and click finish.
The page Product of the Day opens and displays the information that you have entered through the two-step process.
Your comments are welcome!
Did you notice a way we could improve the documentation on this page? Is something unclear or insufficiently explained? Please leave your comments below and we will make the appropriate changes. Comments that have been addressed, by improving the documentation accordingly, will then be removed.
Um using 5.5 and when I submit form1 which goes to from2 at first time only. again when i submit form1 next time itz getting above mentioned error for form2 page.
However when um submitting form2, always geeting above error for product-of-the-page. If u can help me ,itz very helpful to me.
The 5-5 documentation is here: http://dev.day.com/docs/en/cq/5-5/workflows/create-models.html If that doesn't answer your question, may I suggest that you post your question on our dedicated AEM/CQ forum at http://forums.adobe.com/community/digital_marketing_suite/cq5
ADD A COMMENT
In order to post a comment, you need to sign-in.
Note: Customers with DayCare user accounts need to create a new account for use on day.com.
Error while processing /content/mywebsite/en/product-of-the-day-page
Status 500
Message javax.jcr.nodetype.ConstraintViolationException: no matching property definition found for {}product-of-the-day-page
Location /content/mywebsite/en/product-of-the-day-page
Parent Location /content/mywebsite/en
Path /content/mywebsite/en/product-of-the-day-page
Referer http://localhost:4502/content/mywebsite/en/article.form.html/content/mywebsite/en/product-of-the-day-page?wcmmode=disabled
ChangeLog <pre></pre>
Go Back
Modified Resource
However when um submitting form2, always geeting above error for product-of-the-page.
If u can help me ,itz very helpful to me.
If that doesn't answer your question, may I suggest that you post your question on our dedicated AEM/CQ forum at http://forums.adobe.com/community/digital_marketing_suite/cq5
Note: Customers with DayCare user accounts need to create a new account for use on day.com.