On a application that is using BPT, I have a option on the screen for the user to transform um kind of process into another.
The implementation is done by:
This is flow is working almost always, but now and than I'm getting the following error:
"The INSERT statement conflicted with the FOREIGN KEY constraint "OSFRK_ossys_BPM_Event_Queue_OSSYS_BPM_ACTIVITY_ACTIVITY_ID". The conflict occurred in database "OutSystems", table "dbo.ossys_BPM_Activity", column 'Id'.The statement has been terminated."
Looking at the database, I have the Activity on BPM_ACITIVITY so the ID is valid. I don't understand exactly the function of this table Event_Queue - my guess is that tasks/triggers that cannot be executed right now by the BPT Threads will be stored here for a later batch.
Right now, I can't reproduce this error on my development environment - every time I run the functionality it performs has expected.
I would like to know how/when the platform uses ossys_BPM_Event_Queue so I can better debug this problem.
ossys_bpm_event_queue is used by the database triggers for entities used to start process instances or conditionalstart instances.
Consider you have:
- an INVOICE entity that exposes process events- a ProcessInvoice process with a "Launch On" CreateINVOICE
The underlying database table for the invoice entity will have an "after insert/update" trigger that inserts records into OSSYS_BPM_EVENT_QUEUE. That should be the only place where event queue is used for insert.
Hope it helps.
Joao Mateus wrote:
So once I do the update on my record that will invoke the conditional start, that insert on BPM_Event_Queue will be executed - ok.
My question now is what activity is being inserted on BPM_Event_Queue. My guess is that will be the "start" for the conditional. If that is correct, the activity exists on the database and its current status is "listening". I don't see the reason for the INSERT conflict since that key exists.
For the event mechanism to work correctly, the ossys_activity and the osevt_<entityname> tables must be synchronized, meaning the activity_id in osevt_<entity> activity_id needs to point to an existing ossys_activity.
Please check if you have any "dangling" activity_id in the osevt_<entity> names.
It should not happen, but just in case...
Ok, I guess I've found the problem and you are correct. The event table has two activity, one that is referring to the activity of the conditional start and another that no longer exists on BPM_Activity - it must had been purged.
Is there any way to update this table through the platform or I need to delete the row directly on the database?
Please delete it directly from the database as it is not automatically cleaned.
It solved the problem, thank you.