cancel
Showing results for 
Search instead for 
Did you mean: 

CAP Bookshop with Fiori Elements: ' not a valid key' when using selection field with ValueList

tse-gdo
Explorer

I have picked up a strange problem with Fiori Elements when displaying an entity with a GUID as key and then a semantic key used as a selection field on screen. When using the screen without doing a search, everything works fine and when you click to view the details, you can see in network tab a correct drilldown calling URL:
GET Books(ID=f41ea387-5337-446c-9cbe-6062ad8ff851,IsActiveEntity=true)

However if you enter something in the semantic key search field, it for some reason starts getting added to the GET when navigating to details page:
GET Books(ID=f41ea387-5337-446c-9cbe-6062ad8ff851,IsActiveEntity=true,code=201)

As you can imagine, the back-end rejects this GET as code is not a key and you are greeted with error screen image.png.

I tested this on the sample Bookshop example and was able to reproduce the same error so this is not something in my code. I noted that the problem is linked to making the semantic key a ValueList field and hence the search is not a '=201' but rather specific to just '201' in the search field. I do not know why and how this would affect the screen when now navigating to detail page.

See steps below in order to reproduce. Please let me know if I am doing something wrong here or if this is indeed a bug on Fiori Elements itself.

Your environment:

  • @capire/bookshop: 1.0.0
  • @sap/cds: 5.9.2
  • @sap/cds-compiler: 2.13.8
  • @sap/cds-dk: 6.0.3
  • @sap/cds-dk (global): 6.0.3
  • @sap/cds-foss: 3.1.1
  • @sap/cds-mtx: -- missing --
  • @sap/cds-odata-v2-adapter-proxy: 1.8.14
  • @sap/hana-client: 2.12.20
  • @sap/xssec: 3.2.13
  • Node.js: v14.18.3

Steps to reproduce:

  • Download / create standard Bookshop sample project
  • In ./db/schema.cds bring in cuid aspect:
  • Extend Books with cuid and rename ID field to code. Also remove it as key making the ID on the aspect the only key
  • Add `@Common.SemanticKey: [code]` to the Books entity
  • Now generate standard Fiori Elements List-Detail for the project on the admin service Books entity
  • Update the annotation with the following:
annotate service.Books with {
    @(Core.Computed, Common.Text: title)
    ID;

    @Common.ValueList : {
        $Type : 'Common.ValueListType',
        CollectionPath : 'Books',
        FetchValues : 1,
        Parameters : [
            {
                $Type : 'Common.ValueListParameterInOut',
                LocalDataProperty : code,
                ValueListProperty : 'code',
                InitialValueIsSignificant : true,
            },
        ],
    }
    
    @Core.Immutable
    code
};
  • Also add the code as a selection field:
UI.SelectionFields  : [
        code
    ],
  • Now `cds watch` to run the project
  • Open the Fiori Elements screen, type 201 in the search (or using the search help)
  • Now try click on the 201 item to view details
  • Error screen appears with message 'code' is not a valid key
    image.png

Additional information (if applicable):

Accepted Solutions (1)

Accepted Solutions (1)

tse-gdo
Explorer

OSS was raised and SAP has come back with a fix in version 1.105.2 of SAPUI5 libraries. I can confirm the fix is working as expected.

Answers (0)