cancel
Showing results for 
Search instead for 
Did you mean: 

How to use the underlying draft enabled enitity seperately in a Firoi List Report UI ?

Srikar
Active Participant
0 Kudos
74

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? 

Accepted Solutions (0)

Answers (1)

Answers (1)

Willem_Pardaens
Product and Topic Expert
Product and Topic Expert
0 Kudos

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:

https://community.sap.com/t5/technology-q-a/how-to-configure-a-custom-action-that-creates-a-new-obje...

https://community.sap.com/t5/technology-blogs-by-members/prefilling-fields-when-creating-a-new-entit...