This repository demonstrates a possible bug occurring when combining Hierarchical Tree Views with draft-enabled entities (@odata.draft.enabled) in the SAP Cloud Application Programming Model (CAP) and a Flexible Column Layout in the UI5 frontend. Two different annotation approaches for hierarchy trees both result in errors when attempting to edit an entry via the Object Page.
This sample is based on the capire/bookstore repository with the following modifications:
- The example has been simplified and
Genreshas been renamed toEntries. - Added a new entity
Additionalswhich has an association toEntries. manifest.jsonhas been extended with the Flexible Column Layout configuration.- In
app/entries/fiori-service.cds,@odata.draft.enabledand@fiori.draft.enabledhave been added to the service projection. - All
Additonalsassigned to oneEntriesshould be rendered as a table on theEntriesdetail page. - The list report selection navigates to the
Entriesdetail page (->TwoColumnsMidExpanded). AAdditionalsselection on the detail page navigates to theAdditionalsdetail page (->ThreeColumnsEndExpanded).
To reproduce:
npm run init
npm i
cds watchOpen: http://localhost:4004/fiori-apps.html#Entries-display
To switch between the two options, comment/uncomment the respective annotations in app/entries/fiori-service.cds.
When the tree table is annotated using the shorthand @hierarchy annotation (as described in the CAP documentation), navigating from a tree table entry to the Object Page and clicking Edit triggers a server-side SQLite error.
- In
app/entries/fiori-service.cds, enable Option 1 (@hierarchyannotation) and comment out Option 2. - Start the server (
cds watch). - Open http://localhost:4004/fiori-apps.html#Entries-display.
- Click on any entry in the tree table to open the Object Page.
- Click Edit.
A draft should be created and the Object Page should switch to edit mode.
The CAP backend returns the following error:
{
"error": {
"message": "no such column: $E.LimitedDescendantCount in:\nSELECT json_insert('{}','$.\"ID\"',ID,'$.\"name\"',name,'$.\"descr\"',descr,'$.\"parent_ID\"',parent_ID,'$.\"LimitedDescendantCount\"',LimitedDescendantCount,'$.\"DistanceFromRoot\"',DistanceFromRoot,'$.\"DrillState\"',DrillState,'$.\"LimitedRank\"',LimitedRank,'$.\"HasActiveEntity\"',CASE HasActiveEntity when 1 then 'true' when 0 then 'false' END ->'$','$.\"DraftAdministrativeData_DraftUUID\"',DraftAdministrativeData_DraftUUID) as _json_ FROM (SELECT \"$E\".ID,\"$E\".name,\"$E\".descr,\"$E\".parent_ID,\"$E\".LimitedDescendantCount,\"$E\".DistanceFromRoot,\"$E\".DrillState,\"$E\".LimitedRank,? as HasActiveEntity,? as DraftAdministrativeData_DraftUUID FROM CatalogService_Entries as \"$E\" WHERE \"$E\".ID = ? LIMIT ?)",
"code": "SQLITE_ERROR",
"@Common.numericSeverity": 4
}
}When using the manual hierarchy annotation approach instead of the @hierarchy shorthand, the backend does not return an error, but the Fiori UI5 frontend throws a JavaScript runtime error when Edit is clicked, preventing the draft editing session from being initialized.
- In
app/entries/fiori-service.cds, enable Option 2 (manual hierarchy annotation) and comment out Option 1. - Start the server (
cds watch). - Open http://localhost:4004/fiori-apps.html#Entries-display.
- Click on any entry in the tree table to open the Object Page.
- Click Edit.
A draft should be created and the Object Page should switch to edit mode.
No backend error occurs, but the browser console shows the following errors:
Failed to invoke /Entries(ID=543e93cc-c73c-4d1a-9610-20f6aa6e98f1,IsActiveEntity=true)/CatalogService.draftEdit(...)
- TypeError: this.oCache.doReplaceWith is not a function
at E.doReplaceWith (library-preload.js)
at l.handleOperationResult (library-preload.js)
...
sap.ui.model.odata.v4.ODataContextBinding
Error while editing the document - Error: this.oCache.doReplaceWith is not a function
at Object.$ [as createDraftFromActiveDocument] (library-preload.js)
at async n.e [as editDocument] (library-preload.js)
Uncaught (in promise) Error: Error: this.oCache.doReplaceWith is not a function