I need to add a property to a page on page activation. I have decided to set up a workflow process that does the same before an activation step. My custom workflow step (the one before the activation step) makes use of an ECMA script to achieve this. Here's what I have so far.
var workflowData = graniteWorkItem.getWorkflowData();
if (workflowData.getPayloadType() == "JCR_PATH") {
var path = workflowData.getPayload().toString();
var jcrsession = graniteWorkflowSession.adaptTo(Packages.javax.jcr.Session);
var node = jcrsession.getNode(path);
if (!node.hasProperty("foo")){
var cal = Packages.java.util.Calendar.getInstance();
node.setProperty("foo", cal);
node.save();
}
if (!node.hasProperty("foo2")){
node.setProperty("foo2", "2020-08-26T22:30:00.000+05:30");
node.save();
}
}
However, when I run the workflow on a page, the properties that I need to get created (foo and foo2 in this instance) do not get created.
What am I doing wrong?