2025 Mar 19 4:12 PM - edited 2025 Mar 19 4:17 PM
Dear members,
I have Entity A (odata.draft.enabled: true) root view entity with a composition to Entity B & Entity B has it Entity C as composition. I am projecting this with a Fiori List report in using CAP. Now I want to bring out Entity B (odata.draft.enabled: true) and expose it as separate from another Fiori List Report UI.
This is now not allowing me to create an entry as the entity B is already under the Entity A draft capability. This complains to me that DraftAdmistrationData_UUID cannot be null.
How can I do that?
db/schema.cds
Step1 : entity A {
sales: composition to Entity B
}
Step 2: entity B {
salesitems: composition to Entity C
}
Step3: entity C {
}
Service1.cds
odata.draft.enabled : true
entity A
entity B
entity C
Service2.cds
odata.draft.enabled : true
entity B
entity C
The service2.cds does not allow me to create an entry from the object page.
Any thoughts?
Request clarification before answering.
It won't allow you to create on B directly because the composition from A creates a life-cycle dependency. It's like asking a system to create new invoice line items without first telling to which invoice they belong. This makes them orphaned until you 'attach' them to the correct invoice. The solution will be to tell the system from the start which A your new B will belong to. If you don't want to have this tight lifecycle dependency you can switch to normal associations.
To "tell the system from the start which A your new B will belong to" you can do a programmatic creation of the new B (custom action), which will create the new entity, which you can then pop on the screen for the user to complete the details.
To programmatically create new entities, you can use code like the below:
const uuid = generateUUID();
const newB = await srv.create(Entities.B, {
ID: uuid,
Parent_ID: a.ID
});
Have a look at the below as well, depending on what your scenario is:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
11 | |
8 | |
8 | |
6 | |
6 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.