workflows
Jahia 7.3
Jahia 8
Special nodes should have own workflows
Question
Is it possible to have nodes which have an own workflow without inherit it from parent. Without any manual change in workflow tab.Answer
Yes it is possible you can define a simple rule, when this nodetype is created an own worklfow is set.
The rule could look like:
rule "Add default workflow to node"
salience 50
when
A new node is created
- the node has the type mix:yourMixintoBreakWF
then
Add the type jmix:workflowRulesable
Log "Add workflow to " + node.getPath() > WorkflowRuleHelper.addWorkflow(node);
end
Inside the WorkflowRuleHelper.addWorkflow(node)
you can set the default workflow which is expected in my case it looks like:
public static void addWorkflow(NodeFact nodeFact) {
try {
logger.info("set default workspace on node " + nodeFact.getPath());
JCRNodeWrapper node = nodeFact.getSession().getNode(nodeFact.getPath());
if (node.hasNode("j:workflowRules")) {
JCRNodeWrapper wfRules = node.getNode("j:workflowRules");
if (!node.hasNode("jBPM_1-step-publication-remotepublish")) {
JCRNodeWrapper rule = wfRules.addNode("jBPM_1-step-publication-remotepublish", "jnt:workflowRule");
rule.setProperty("j:workflow", "jBPM:1-step-publication-remotepublish");
rule.saveSession();
}
}
} catch (RepositoryException ex) {
logger.error("Error when set default workflow on node ", ex);
}
}