on 02-07-2023 12:07 PM
Hi,
I have built a SAP CAP application with fiori elements using a local odata v4 service.
The minimal entity definitions are as follows
annotate Solutions with @odata.draft.enabled;
entity Solutions : cuid {
name : String(100);
description : String(255);
services : Composition of many RequestedServices
on services.solution = $self;
}
entity RequestedServices : cuid {
expectedMonthlyUsage : Integer;
maxUsage : Integer;
warningUsage : Integer;
solution : Association to Solutions;
}
The annotations have been setup in a fiori-service.cds file as follows:
//Solutions List Report and Object Page
annotate service.Solutions with @(
UI : {
HeaderInfo : {
$Type : 'UI.HeaderInfoType',
TypeName : '{i18n>Solution}',
TypeNamePlural : '{i18n>Solutions}',
Title : {
$Type : 'UI.DataField',
Value : name
},
Description : {
$Type : 'UI.DataField',
Value : description
}
},
Identification : [{Value : name}],
LineItem : [
{Value : name},
{Value : description}
],
Facets : [{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>RequestedServices}',
Target : 'services/@UI.LineItem'
}],
FieldGroup #Main : {
$Type : 'UI.FieldGroupType',
Data : [
{Value : name},
{Value : description}
]
},
HeaderFacets : [{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>SolutionDetails}',
Target : '@UI.FieldGroup#Main'
}]
},
//To allow updatable on child "RequestedServices" entity
Capabilities : {
NavigationRestrictions : {
RestrictedProperties : [
{
NavigationProperty : services,
UpdateRestrictions : {
Updatable : true
}
}
]
},
}
);
//Requested Services List Report in Object page
annotate service.RequestedServices with @(
Capabilities.UpdateRestrictions : {
Updatable: true
},
UI : {
HeaderInfo : {
$Type : 'UI.HeaderInfoType',
TypeName : '{i18n>RequestedService}',
TypeNamePlural : '{i18n>RequestedServices}'
},
LineItem : [
{
Value : entitledService_ID,
![@Common.FieldControl] : #ReadOnly
},
{
Value : servicePlan_ID,
![@Common.FieldControl] : #ReadOnly
},
{
Value : expectedMonthlyUsage,
![@Common.FieldControl] : #ReadOnly
},
{Value : warningUsage},
{Value : maxUsage},
{
Value : cost,
![@Common.FieldControl] : #ReadOnly
},
{
Value : costCurrency_code,
![@Common.FieldControl] : #ReadOnly
}
]
}
);<br>
In the manifest.json of the fiori app I have also set the "editableHeaderContent" to true for the object page
"RequestedServicesObjectPage": {
"type": "Component",
"id": "RequestedServicesObjectPage",
"name": "sap.fe.templates.ObjectPage",
"options": {
"settings": {
"editableHeaderContent": true,
"entitySet": "RequestedServices"
}
}
}<br>
When I run the application, I am able to view and click the edit button which gets the page into edit mode.
This seems as expected behaviour. However, when I enter any data in the editable fields in the table of Requested Services (which is a child entity of Solutions), I get an error
I was expecting that based on the annotations set for NavigationRestrictions, Updatable: true on the parent Solutions entity and the Capabilities.UpdateRestrictions {Updateable: true} on the child RequestedServices entity, it would set the table to draft mode (i.e it would internally set the IsActiveEntity=false flag on the RequestedServices entity) so the child records could be edited.
I tried following the documentation at https://sapui5.hana.ondemand.com/sdk/#/topic/5c8763f0fb1f4cc7aaab6cc19d5ee45c.html but I could not get this to work.
Any solutions on how to edit records of a child entity in a table of an object page ?
Regards,
Melwyn
So after some more investigation, it seems the issue is instead with cds-pg adapter for PostgresDB and it works fine with sqlite.
Here is a link to a similar issue:
https://github.com/sapmentors/cds-pg/issues/381
Hopefully this helps others 🙂
Regards,
Melwyn
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
11 | |
8 | |
8 | |
6 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.