[Case Management framework] How do I end a Wait activity after a BAPI returns Success
case-management-framework
Service icon
Forge component by Platform Maintenance
Application Type
Reactive

Hi All,

I'm have a requirement where I need to pause the Approval workflow until the data is integrated with another system. So I'm using the Wait activity to hold the flow until the BAPI return success. To Close the wait activity I only get two Entity Actions, where I don't have the actual entity option where the data is updated. How do I stop the Wait after my Integration is successful? 

The idea of this pattern is to periodically try to close the Wait activity by checking if your external system has finished its job and either wait more time or close the activity and move forward with the workflow. I'll try to explain further:

  1. You set a Timeout for the wait activity. In this example lets say you want to call the external system every 5 minutes to check if it has finished its job. You'd set the Timeout property to the following function: AddMinutes(CurrDatetime(),5) This means that from the point in time your workflow has reached that Wait activity, every 5 minutes it will timeout and try to close the activity.
  2. Add an OnClose callback action to the Wait activity. This action will be triggered whenever the Wait activity is about to be closed (every 5 minutes when it times out, because we set it up like that in the previous step). Inside this action you will make the request to your external system's API and check its response. If the response from the API:
    • is positive, meaning the external system has finished its job. You end the flow of the OnClose callback action with an End node. This will make the Wait activity close and move forward with in your workflow.
    • is negative, meaning the external system hasn't finished its job yet. You end the flow of the OnClose callback action with a Raise Exception node. Raising this exception that will not be handled (don't add an exception handler to the callback action) will result in the Wait activity to be retried. Meaning that it will wait another 5 minutes (the timeout value) before trying to close itself again. This way, the Wait activity will repeat itself till the API returns a positive message.

Regarding the question of updating the status, I'm assuming you are talking about a Case's status in the context of the Case Management framework. If that's the case you can use the Case_UpdateStatus server action from the CaseServices_API module.

Thank you for the clear explanation. That solves the confusion I had.

Hi Monika, 


There are many ways you can tackle this use case. Since you say you don't have access to the entity that gets updated I'm guessing using the "Close On" property of the activity is not an option. 

I'd say your best bet would be to make use of the "Timeout" property in tandem with the "OnClose" callback action to tentatively close the activity and poll your external system for a success message. You can read more about this pattern here and here. Hope this helps. Feel free to reach out if you still have doubts about this pattern.


Kind regards,

André Ramada

Hi André ,

I explored that option as well.. Since waiting is based on the result of integration I don't have a fixed time for the timeout. I'm trying to achieve something like If(Bapi.isSuccess, currdatetime(), nulldatetime()..?). Also I would like to know what happens when we pass nulldatetime() will it continue to wait or elapse..

There are two scenarios now.. Either BAPI returns success then stop the wait immediately and change status as "Approved" and continue to next step or BAPI return error then change status to "Failed" and continue waiting .. I'll run a timer to retrigger the BAPI to try again later.

 This article really helped in understanding about the wait activity with API integration but I have to change the status based on the result of the BAPI before continuing with the next step which I'm not sure how to achieve. 

The idea of this pattern is to periodically try to close the Wait activity by checking if your external system has finished its job and either wait more time or close the activity and move forward with the workflow. I'll try to explain further:

  1. You set a Timeout for the wait activity. In this example lets say you want to call the external system every 5 minutes to check if it has finished its job. You'd set the Timeout property to the following function: AddMinutes(CurrDatetime(),5) This means that from the point in time your workflow has reached that Wait activity, every 5 minutes it will timeout and try to close the activity.
  2. Add an OnClose callback action to the Wait activity. This action will be triggered whenever the Wait activity is about to be closed (every 5 minutes when it times out, because we set it up like that in the previous step). Inside this action you will make the request to your external system's API and check its response. If the response from the API:
    • is positive, meaning the external system has finished its job. You end the flow of the OnClose callback action with an End node. This will make the Wait activity close and move forward with in your workflow.
    • is negative, meaning the external system hasn't finished its job yet. You end the flow of the OnClose callback action with a Raise Exception node. Raising this exception that will not be handled (don't add an exception handler to the callback action) will result in the Wait activity to be retried. Meaning that it will wait another 5 minutes (the timeout value) before trying to close itself again. This way, the Wait activity will repeat itself till the API returns a positive message.

Regarding the question of updating the status, I'm assuming you are talking about a Case's status in the context of the Case Management framework. If that's the case you can use the Case_UpdateStatus server action from the CaseServices_API module.

Thank you for the clear explanation. That solves the confusion I had.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.