on 10-22-2023 11:23 AM
Dear community,
I am new to CAP and try to set up a little learning project.
I have to 2 entities: Employees & Vacations associated to each other.
My schema looks like this:
namespace pd.praxissuite;
entity Vacations {
key ID : UUID;
startDate : Date; @mandatory
endDate : Date; @mandatory
employeeID: String;
employee : Association to Employees on employee.ID = $self.employeeID;
note : String;
}
entity Employees {
key ID : UUID;
firstName : String; @mandatory
lastName : String; @mandatory
vacations : Association to many Vacations on vacations.employeeID = $self.ID;
}
Corresponding service:
using pd.praxissuite as praxissuite from '../db/data-model';
service vacationplan {
entity Vacations as select from praxissuite.Vacations;
entity Employees as select from praxissuite.Employees;
}
annotate vacationplan.Employees @odata.draft.enabled;
annotate vacationplan.Vacations @odata.draft.enabled;
I created a Fiori Elements List Report using Fiori Tools with Employees as main entity, leading to an Object Page with a section listing all Vacations in a table.
I can create and save new Employee without error. When I try to create a new Vacation entity on the detail page it fails with following error in cds watch console:
Hope someone can help.
Thanks a lot in advance,
BR,
Philipp
Given you are enabling drafts I think you want to switch the association to Vacations in the Employee entity to a Composition. the back link can stay as an association to one (you don’t need the on-part). Try that first and give it another test
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jason,
thanks a lot for your super quick reply. This seems to save my sunday.
I changed the schema to use a composition and needed to delete the odata draft annotation for vacations in the service.
Now it is working as expected - but I don't fully understand why. Could you elaborate a little on your suggestion with the composition?
Is there any way to use CAP with FE without utilizing the draft capabilities?
Thank you so much,
Philipp
Somehow whenever I paste something in the code blocks - after saving it is not in anymore leading to above result. Sorry for that, still trying to find a way how this is done...
It seems to work here in the comment section, so:
schema:
namespace pd.praxissuite;
entity Vacations {
key ID : UUID;
startDate : Date; @mandatory
endDate : Date; @mandatory
employeeID: String;
employee : Association to Employees on employee.ID = $self.employeeID;
note : String;
}
entity Employees {
key ID : UUID;
firstName : String; @mandatory
lastName : String; @mandatory
vacations : Association to many Vacations on vacations.employeeID = $self.ID;
}
service:
using pd.praxissuite as praxissuite from '../db/data-model';
service vacationplan {
entity Vacations as select from praxissuite.Vacations;
entity Employees as select from praxissuite.Employees;
}
annotate vacationplan.Employees @odata.draft.enabled;
annotate vacationplan.Vacations @odata.draft.enabled;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
70 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.