Hi @raja_reddy
To address your inquiry, allow me to pose a few more questions:
Is your customized code running successfully? If not, the problem might lie in the launcher configuration.
If the custom code is being invoked but the page properties are not updating, the issue could be related to your code or permissions.
Here is the sample code for workflow -
@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap args) throws WorkflowException {
WorkflowData workflowData = workItem.getWorkflowData();
String payloadPath = workflowData.getPayload().toString();
String customProperty = args.get("customProperty", String.class); // get the custom property name from the dialog
String customValue = args.get("customValue", String.class); // get the custom property value from the dialog
ResourceResolver resolver = null;
try {
Map<String, Object> param = new HashMap<>();
param.put(ResourceResolverFactory.SUBSERVICE, "workflow-service");
resolver = resolverFactory.getServiceResourceResolver(param);
Resource resource = resolver.getResource(payloadPath);
if (resource != null) {
Node node = resource.adaptTo(Node.class);
if (node != null) {
if (node.hasProperty(customProperty)) { // check if the node already has the custom property
node.setProperty(customProperty, customValue); // update the custom property value
} else {
node.setProperty(customProperty, customValue); // add the custom property to the node
}
resolver.commit();
}
}
} catch (RepositoryException e) {
throw new WorkflowException(e.getMessage(), e);
} finally {
if (resolver != null) {
resolver.close();
}
}
}
Moreover, if the sole requirement is to add/update the custom page properties, have you considered exploring the option of event listeners?
In terms of performance, an event listener proves to be faster than a workflow. This is because it is triggered asynchronously, avoiding the overhead of creating workflow instances and nodes. On the contrary, a workflow tends to be slower and consumes more resources due to its involvement in multiple steps and transitions.