Expand my Community achievements bar.

SOLVED

How can I call a servlet/service call for every workflow Approve and Reject action.

Avatar

Level 1

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.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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.Shailesh_Bassi__1-1684262604369.png

 

This approach is ideal when the processing logic for approval and rejection is complex and should be kept segregated.

Hope this helps!

Thanks

View solution in original post

2 Replies

Avatar

Level 4

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

Avatar

Correct answer by
Community Advisor

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.Shailesh_Bassi__1-1684262604369.png

 

This approach is ideal when the processing logic for approval and rejection is complex and should be kept segregated.

Hope this helps!

Thanks