Question about AfterCheckinChangesFinalize in VAF

Hello,

We are currently using a custom application to send email notifications to external users, based on workflow triggers.

This application relies on the AfterCheckinChangesFinalize event.

In some situations, we observe that an email is sent even though the object update is ultimately not validated. To clarify the scenario:

  • The workflow transition itself is validated.

  • However, during the persistence to the SQL database, a SQL deadlock can occur.

  • This causes the transaction to fail and be rolled back.

  • As a result, no change is visible in the object history.

  • Despite this rollback, the email notification has already been sent.

From our understanding, this means that AfterCheckinChangesFinalize is triggered even though the overall transaction is not fully completed or committed.

We therefore have two questions:

  • Is this behavior expected and considered normal?

  • If so, what would be the recommended best practice to avoid sending notifications in such cases?

Related to this, we would also like to confirm whether M-Files Advanced Notifications rely on the same AfterCheckinChangesFinalize trigger, or if a different mechanism is used to ensure transactional consistency.

Thank you in advance for your feedback.

Best regards,
Allan Mietton

Parents
  • AfterCheckInChangesFinalize still occurs within the transaction so there are still chances it will not be committed.  Other event handlers could attach to the same event and throw exceptions after yours has run, for example.

    If you need to be 100% sure then use the AfterCheckInChangesFinalize event to put a task into a task queue.  If you do this using the transactional vault reference then the task will only be committed if the transaction is committed.  Then use a task processor to do whatever work you need (e.g. send the email), as this will monitor for tasks and run them (which it'll only find if the transaction actually committed).

    This pattern is often the best way to deal with telling external systems that something definitely happened. You can pass the ObjID or ObjVer data of the object into the task using the directive (if you use the VAF Extensions then it has built-in directives to help with this).  You then read the directive back out in the processor to then work out which object changed, and send the data to the external system.

Reply Children