You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some time ago we have discussed missing possibility to add changelog changes for an entity that is being processed not from a service (for example, UI service) but is inserted or updated directly on DB.
Meanwhile this issue was solved: we created Wrapper-Services for the involved entities and this solved even the second issue where a view was defined as a union of three different entities and we were not sure how to define change tracking for this.
It looks like (srv\payment\wrapper\wrapper-service.cds):
service PaymentWrapperService @(requires: 'system-user') {
entity Payments as projection on db.payments.Payments;
entity Payables as projection on db.payables.Payables;
entity PaymentOrders as projection on db.paymentOrders.PaymentOrders;
entity Receivables as projection on db.receivables.Receivables;
entity BusinessTransactions as projection on db.businessTransactions.BusinessTransactions;
}
BusinessTransactions is the mentioned view which is a union of Payments, Receivables and Payables.
Now all our DB operations relevant for change-tracking are defined via this service, for example
This works; the changes for all involved entities are written back and shown in the app “business Transactions” based on an UI service defined on the entityBusinessTransactions.
However there is one strange thing.
For creating the entities change logs are written both if you test locally or in the main test system https://c4b-main02-subscriber-1.c4b-main02.dev01.eu.canary.clusters.cs.services.sap/.
However these entities can be also updated. This is happening not from UI but from an Event Handler reacting on some events. For example if a Transfer Order which was created for a Payment becomes completed then the corresponding Payment gets status “Completed” as well. The event is thrown during a job run. Updating the Payment is fulfilled via WrapperService in lib\payment\payments\DbPaymentRepository.ts.
Now if I am testing this event processing locally then I see that the changes with modification = “update” are inserted into CHANGELOG and CHANGES. Unfortunately I cannot execute the mentioned job (it is running only in MAIN system). But I tested this from a unit test firing the same event and the update changes were created.
When the job is running in MAIN and payments are updated with the new status “Completed” it is however not reflected in CHANGELOG and CHANGES.
Do you have any idea what can be the difference? We supposed that this was due to the job execution. But we have other events which are creating new instances of Payment – and this works; the “create” changes are created.
What in MAIN environment could inhibit creating “update” change logs?
Kind regards,
Elena Gurevich
The text was updated successfully, but these errors were encountered:
032660
changed the title
"Updated" change logs are not created in the main test system
"Update" change logs are not created in the main test system
Apr 17, 2024
I executed some tests and checked created entities. Could you please confirm that an "update" modification creates a change log only if "modifiedAt" or "modifiedBy" has changed after this update?
I suppose that it is so because there is:
// Since req.diff() will record the managed data, change history will filter those logs only be changed managed data
const managedAttrs = ["modifiedAt", "modifiedBy"]
if (curChange.modification === "update") {
const rowOldAttrs = Object.keys(childNodeChange._old)
const diffAttrs = rowOldAttrs.filter((attr) => managedAttrs.indexOf(attr) === -1)
if (!diffAttrs.length) {
return
}
}
If I am right then you can close this issue because I found out that neither modifiedAt nor modifiedBy was changed for the entities for which update change log is missing.
Hi colleagues,
We are working on the project https://github.tools.sap/erp4sme/crypto-for-business.
Some time ago we have discussed missing possibility to add changelog changes for an entity that is being processed not from a service (for example, UI service) but is inserted or updated directly on DB.
Meanwhile this issue was solved: we created Wrapper-Services for the involved entities and this solved even the second issue where a view was defined as a union of three different entities and we were not sure how to define change tracking for this.
It looks like (srv\payment\wrapper\wrapper-service.cds):
service PaymentWrapperService @(requires: 'system-user') {
entity Payments as projection on db.payments.Payments;
entity Payables as projection on db.payables.Payables;
entity PaymentOrders as projection on db.paymentOrders.PaymentOrders;
entity Receivables as projection on db.receivables.Receivables;
entity BusinessTransactions as projection on db.businessTransactions.BusinessTransactions;
}
BusinessTransactions is the mentioned view which is a union of Payments, Receivables and Payables.
Now all our DB operations relevant for change-tracking are defined via this service, for example
UPDATE.entity(WrapperService.Entity.Payments).where({ ID: paymentToUpdate.ID }).with(paymentToUpdate);
This works; the changes for all involved entities are written back and shown in the app “business Transactions” based on an UI service defined on the entityBusinessTransactions.
However there is one strange thing.
For creating the entities change logs are written both if you test locally or in the main test system https://c4b-main02-subscriber-1.c4b-main02.dev01.eu.canary.clusters.cs.services.sap/.
However these entities can be also updated. This is happening not from UI but from an Event Handler reacting on some events. For example if a Transfer Order which was created for a Payment becomes completed then the corresponding Payment gets status “Completed” as well. The event is thrown during a job run. Updating the Payment is fulfilled via WrapperService in lib\payment\payments\DbPaymentRepository.ts.
Now if I am testing this event processing locally then I see that the changes with modification = “update” are inserted into CHANGELOG and CHANGES. Unfortunately I cannot execute the mentioned job (it is running only in MAIN system). But I tested this from a unit test firing the same event and the update changes were created.
When the job is running in MAIN and payments are updated with the new status “Completed” it is however not reflected in CHANGELOG and CHANGES.
Do you have any idea what can be the difference? We supposed that this was due to the job execution. But we have other events which are creating new instances of Payment – and this works; the “create” changes are created.
What in MAIN environment could inhibit creating “update” change logs?
Kind regards,
Elena Gurevich
The text was updated successfully, but these errors were encountered: