cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP CAP - Assert reference integrity error thrown when using ID returned from after handler

WilliamW
Explorer
0 Likes
1,268

In the after create event handler of an entity (FundsAllocationReport), I am performing some logic and creating some data to insert into a table associated with the entity (CustomerClaims). As part of the payload in the INSERT statement I provide the ID of the recently created entity (FundsAllocationReport).

What is happening is, intermittently, CAP is throwing ASSERT_REFERENCE_INTEGRITY error on the ID.

Above is data sent by After create handler

The same ID returned by After create handler is not in the database??? How is this possible??

Here also is the data model:

This must be framework bug?? CAP fires the after event on create before the entity is created on the database??

Accepted Solutions (0)

Answers (1)

Answers (1)

mauriciolauffer
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi,

Replace Association by Composition (https://cap.cloud.sap/docs/cds/cdl#associations). My guess is the data hasn't been committed to the database yet.