Skip to Content
0
May 01, 2020 at 11:52 AM

Referencing a field from a foreign entity in an ObjectPage table

220 Views

Hi

Can anyone offer an approach to this.

I am working on a use case for maintaining people using business partner design. In this design a person can take on one of more roles. Below is a diagram of the normalised data model I have created thus far which seems to be working to a point.

I have been able to do the following without having to maintain a service.js file. I.e. the CDS engine supports all crud operations out of the box (which is pretty impressive work from the CDS team). Until now I can:

  • create a Person,
  • store the draft version of Persons and Person_Role
  • create a new role (while in edit mode),
  • use the search help to search for a Person_Role.ID value where the search-help is referencing the Role entityset

To make the ObjectPage more meaningful to a user, I would like to add a column for Role Name that will show the corresponding name (Role.roleName) for the selected Role ID.

Is there a way to do this while maintaining a normalised data model?

Thanks in advance:

P.S:

I did attempt the approaches mentioned in https://blogs.sap.com/2019/08/21/computed-field-example-in-cap/.

I found that DJ Adams approach resulted in an "SQLITE_ERROR: no such column: roleName" when creating a new Person_Role - Possibly requiring some intervention to remove the computed roleName field and then create the insert manually

(see: https://github.com/scongia/or-assistant/commit/cfa0e096e52b98a3a380140df8fa6d2014d50657).

I then tried Pierre Dominique approach but this resulted in a compile error on AdminService saying "AdminService.Person_Role" of autoexposed entity for "com.or.assistant.Person_Role" collides with other definition - possibly because to Persons has a @odata.draft.enabled annotation

(see: https://github.com/scongia/or-assistant/commit/994cb183d29c1bb6c3a03423c7599383056733dc)

Attachments