BPM, Workflow, and Case

 View Only

 How to complete "User Task" (CSHS) using REST API, as if user clicked CSHS button

Zarko Zunic's profile image
Zarko Zunic posted Thu January 23, 2025 07:00 AM

Greetings everyone, 

This is my process in BAW 20:

"User Task 1" is implemented using  Client-Side Human Service (CSHS) named "Klijent".

This is implementation of CSHS named Klijent.

The question is how to complete this user task with REST API as if the user opened the task and clicked a Button 1, Button 2 or Button 3?

I tried to use this REST api REST interface for BPD-related resources - Task Instance Resource - PUT (complete, finish) Method   and task did complete, but none of the scripts (Button 1 clicked script...)) from the image didn't execute. I need everything to execute alognside desired flow before task completes.

In my real world scenario those are ECM service and YAML Specified external service calls instead of scripts.

Best Regards

Žarko

 

Atanu Roy's profile image
Atanu Roy IBM Champion

Hello @Zarko Zunic,

You cannot perform anything inside the CSHS when the task is completed using REST/JS API.

I am assuming you are setting a variable to determine which button is clicked. If that is so, then I can suggest you an alternative - create an output variable in the CSHS, map that output variable to a process level variable in the task's data mapping. Then, while completing the task using REST/JS API, set that variable with a proper value which will simulate the same behavior as the button click. 

In case of REST API, you can use the parameters to set the variable of the task. 

Thanks!

Zarko Zunic's profile image
Zarko Zunic

Hi @Atanu Roy

Thank you for your answer.

When completing a Client-Side Human Service (CSHS) task using a REST API call, the task completes without executing service flows inside the CSHS.

In contrast, If  an end user  completes task through COACH UI, those service flows would execute after a button was clicked, but before task completes.

I partially did as you suggested:

  • Set the output variable of the CSHS using the REST API completion call.
  • Moved service execution from CSHS to the process level to ensure it runs even when REST completon is used.

Since REST API calls bypass service flows inside CSHS, I had to modify the process definition and run those flows at the process level instead.

Thank you!

Žarko

Thank you!