on 11-25-2023 10:38 AM
Hello community,
let's say we have a data model as follows:
using { managed } from '@sap/cds/common';
namespace employee.catalog;
entity Student {
key studentID: UUID;
studentName: String;
courses: Composition of many StudentToCourse on courses.student = $self;
}
entity Course {
key courseID: UUID;
courseName: String;
students: Composition of many StudentToCourse on students.course = $self;
}
entity StudentToCourse {
student: Association to Student;
course: Association to Course;
}
Is there a way I can create a fiori elements UI to assign Students to Courses? I am thinking of a list report for students and on the object page a table that lists assigned courses including the option to assign new courses to the student.
Thanks!
Philipp
Philipp,
two things that come to mind. First, entity names should be in the plural form, i.e. "entity Students...." and "entity Courses....". If you want navigation properties, then prefer Associations over Compositions. The latter is more suitable for entities with a header-item (one-to-many) relationship.
See Compositions
You should be able to use a @UI.ReferenceFacet in the Student object page to list all courses. Annotations should give you add/delete capabilities. Alternatively, you may start with a custom page and use the flexible programming model.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Ulrich,
thank you for the answer.
Regarding the entity names: above example was just copied from this blog:
https://blogs.sap.com/2023/07/26/understanding-relationship-types-in-sap-cap-one-to-one-one-to-many-.../
I was reading it and wondering whether FE UIs would be a good/ feasible approach to maintain many-to-many associations...
User | Count |
---|---|
77 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.