Keeping the UI and Human Activity State in Sync

Good morning,

Part of our application is for users to request approval for various types of documentation that they create.  The BPT process is quite complex.  There is the "main" process that guides the approval flow, and a point there are child processes that are called that create the Human Activities (that's all they are responsible for, sending the HA to 2 people and wait for one of them to complete the task).

It is important to understand that our application data is not held within Outsystems entities, we use our own API to CRUD our data in an on-premise DB.  We do however use Outsystems data to control our workflows so that we can use Human Activities to control the approval process more easily.

So the User clicks the "Request Approval" button whose action starts the process, part of which is to send an HA to the user configured to perform the approval (It has to go to specific user rather than a group).  This action also calls the API to update the status of the documentation to "Pending Approval"  The UI gets refreshed at the end of that action to show the appropriate buttons. With me so far?

Recently a change was requested that the same user can both "request approval" and "approve" their own document. What I have found is that it is very easy for the UI, DB and BPT control data to get out of sync. A user can click "Request Approval", wait for the UI to update and present them with the "Approve" button and click it before the Human Activity has been served to them due to the asynchronous manner in which a Process is started. The result is that the Human Activity is waiting for an activity that has already been completed.

What are peoples thoughts around this? My immediate fix has been to add a delay into the "Request Approval" action that waits for the HA to be served before refreshing the UI. This works, but my surprise is that this can 20 seconds to happen! The process is also responsible for sending the emails to the approval users notifying them. Could it be having a process calling a child process to serve the HA and wait for it to be done is a bad idea?

Thanks in advance.

Hi Martin,

It seems you are processing frequent server action in a single server call. commit the transaction once the human activity is completed by the user. check in BPT, you are correctly ending/terminating the process once the human activity is completed. Hope above might help you..

Thanks, Aadhavan S

Hi Martin, replying to your initial question as I have recently investigated that particular behavior.

Indeed the activities in the OutSystems BPT will progress asynchronously if you are using Entity Events to automatically close the Activities (Create<ENTITY>, Update<ENTITY>, etc.). So in that circumstance if you have a user navigating from Screen 1 where he executes Human Activity 1 to Screen 2 where he executes Human Activity 2, when the second screen is loaded the BPT activity might not yet have been opened yet, which can have impact on your logic.

 In order to avoid this asynchornous behavior, you can use the BPT API to close the activity with the Close<Human Activity Name> process action or ActivityClose system action. This means that instead of defining in your process that Human Activity 1 closes on a particular database event, you would explicitly call the ActivityClose action in your Screen 1 logic once the activity is finalized - this will synchronously close Human Activity 1 and set the Human Activity 2 as ready, which means that once you get to the second screen you will have the process up-to-date.

Hope this helps.

Kind Regards,


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