Problem
You want to know how rules work in workflows and what they are used for.
Resolution
Rules in workflows are used for XOR Splits only.
If you process a workflow with a XOR Split you have to select one of the available routes (transitions) to the parallel Steps (in contrary to a workflow with an AND Split where every parallel Step has to be completed).
With the rule of a route you can define if this route should be displayed in the route selector or not.
The Rule must be a ECMA script located in /etc/workflow/scripts
with a function check()
where you can implement your logic. The function must return a boolean value.
Available objects are:
workflowData
(workflowData)workflowSession
(WorkflowSession)jcrSession
Example
A very simple example rule script would be to check if the current page in the workflow is the geometrixx company page or a childpage.
* * Example WF Rule. * ECMA function with a method called check * * This function checks if the current page in workflow is in the company tree * of geometrixx... * * Available Objects: * - workflowData: * - jcrSession: * - workflowSession: */ function check() { log.info("executing script now..."); if (workflowData.getPayloadType() == "JCR_PATH") { var path = workflowData.getPayload().toString(); var node = jcrSession.getItem(path); if (node.getPath().indexOf("/content/geometrixx/en/company") >= 0) { return true; } else { return false; } } else { return false; } }
As attachment you will find a package (ExampleRuleWorkflow-1.0-1.zip) with this script and an example workflow with one step Step 1
above the XOR Split and two parallel steps Left Step
and Right Step
.
The route (transition) from Step 1
to Left Step
has a Roule with the script above.
If you start the workflow you are on Step 1
and can select the route to Right Step
always, independent on the current page in the workflow.
The route to Left Step
is only available if the current page in the workflow is the geometrixx company page or a childpage...
Applies to
CQ5.2+
下載