Team,
I need to make a service call for every workflow approve and reject actions. Is there any way to capture Approve and Reject actions of workflow. OR else JS is also fine.
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @Racer3189
There are multiple ways to handle this case:
Approach I:
As stated by @raushan123 Basically in the next step of the workflow where you are either approving or rejecting it, one can created a process step for reading the args and then based on it perform the next steps
Sample code for reading the arguments and calling the service is
@Reference
ContentApprovalWorkflowService contentApprovalWorkflowService;
public void execute(WorkItem item, WorkflowSession session, MetaDataMap args) throws WorkflowException {
if (args.containsKey("PROCESS_ARGS")){
if(args.get("PROCESS_ARGS","string").toString().equalsIgnoreCase('Approved'){
contentApprovalWorkflowService.publish(payload);
}
contentApprovalWorkflowService.addLog(payload);
}
}
Approach II: Create seperate business logic and there is no need for reading the args.
Based on the selection from the participant or dynamic participant step the respective process step can be called which can call the service using the @Reference Annotation.
This approach is ideal when the processing logic for approval and rejection is complex and should be kept segregated.
Hope this helps!
Thanks
Basically, you have to pass action (approve or reject ) through model
and below approve or reject step you have to configure one custom process step
and in that custom process step java code.
you have to capture the argument
String argument = metDataMapargs.get(WORKFLOW_PROCESS_ARGS, String.class);
based on this you can find whether it's approved or reject
Hi @Racer3189
There are multiple ways to handle this case:
Approach I:
As stated by @raushan123 Basically in the next step of the workflow where you are either approving or rejecting it, one can created a process step for reading the args and then based on it perform the next steps
Sample code for reading the arguments and calling the service is
@Reference
ContentApprovalWorkflowService contentApprovalWorkflowService;
public void execute(WorkItem item, WorkflowSession session, MetaDataMap args) throws WorkflowException {
if (args.containsKey("PROCESS_ARGS")){
if(args.get("PROCESS_ARGS","string").toString().equalsIgnoreCase('Approved'){
contentApprovalWorkflowService.publish(payload);
}
contentApprovalWorkflowService.addLog(payload);
}
}
Approach II: Create seperate business logic and there is no need for reading the args.
Based on the selection from the participant or dynamic participant step the respective process step can be called which can call the service using the @Reference Annotation.
This approach is ideal when the processing logic for approval and rejection is complex and should be kept segregated.
Hope this helps!
Thanks
Views
Likes
Replies