

CAPM-(Node JS) Deep Insert - Not triggering custom logic
source link: https://answers.sap.com/questions/13653416/capm-node-js-deep-insert-not-triggering-custom-log.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

CAPM-(Node JS) Deep Insert - Not triggering custom logic
Hello,
I was trying to follow along with a blog post written by Carlos Rogan. But while posting it's not even triggering custom logic to manipulate/map things as been described in this blog post.
data-model:
namespace com.relation;entity CompanyEntity { key companyId : Integer; companyName : String; linkToContact : Association to ContactEntity;}entity ContactEntity { key contactId : String; contactName : String; contactPhone : Integer; }Service
using com.relation from '../db/schema';@path: '/browse'service RelationService { entity CompanyEntity as projection on relation.CompanyEntity; entity ContactEntity as projection on relation.ContactEntity;}
Custom logic
const cds = require('@sap/cds')module.exports = cds.service.impl( function(){ this.on('CREATE', 'CompanyEntity', (req)=>{ // const {CompanyEntity} = this.entities; console.log(req.data); })})Yes, I know, this custom piece doesn't contain any logic yet but wondering why logging is being failed even. This code gets triggered only when I am posting data only for CompanyEntiy but not as a deep insertion.
test.http
POST http://localhost:4004/browse/CompanyEntity HTTP/1.1Content-Type: application/json{"companyId": 3,"companyName": "BeerShop","linkToContact_contactId": "ContactForBeerShop","linkToContact": { "contactId": "ContactForBeerShop", "contactName": "Peter", "contactPhone": 9876543 }}
error received:

Any suggestion will be helpful.
Thanks.
Please try to format your quesiton better.
Thanks Gregor,
My question is:
Deep insert doesn't come out as a default feature and hence it needs an explicit implementation/hook to achieve.
I have created the implementation and this is supposed to get triggered while I will make a POST entry with a deep insert. The issue is, that the implementation doesn't get triggered and it ends up with the error message as mentioned in a screenshot.
I want to call out, that the implementation only gets triggered if I do a normal create against the entity "CompanyEntity " which means without a deep insert process.
So why implementation is NOT getting triggered during the deep insert process is what I am keen to know.
Thanks for any pointers.
BR, Somnath
</div
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK