Skip to Content

Fiori Elements: Filter based on association property

Hi folks,

im facing a strange Problem in the "ListReport" of the Fiori Elements and hope you can help me to fix my issue. :)

My requirement is to provide some filter-options for the starting Table based on an association. (for example the List shows some SalesOrder Headers and on the Object Page also the SalesOrder Items are provided. And now the User wants just to see the SalesOrder Headers where an Item is included with the Product "XY")

After looking into the CDS-Help i thought that the following Code would work:

define view ZCDS_C_SalesOrder_00 
  as select from ZCDS_I_SalesOrder_00 as SalesOrder 
  association [0..*] to ZCDS_C_SalesOrderItems_00 as _Items on _Items.SalesOrderUUID = SalesOrder.SalesOrderUUID


    @UI.selectionField: [{ element: '_Items.Product', position : 2 }]

But unfortunately the Filter for the Product is still not visible in the Filterbar, even under "more Filters".

The CDS-Help (Link to Help) says for UI.selectionField.element the following:

Must be used when an association is annotated, the value is a path to an element of the associated view. You use this option if you want to filter a table for a column that is not defined in your CDS view but in another CDS view.

Example:You define a sales order view in which you want to filter business partners for their country of origin. However, these country information are not maintained in the sales order view but in the business partner view.

So i thought this is exactly what im looking for, but it seems not. :-D

Has anyone an idea how to achieve the requirements with CDS Annotations?

As always any kind of informations is appreciated.

Thanks for your help!


Add a comment
10|10000 characters needed characters exceeded

  • @Susmitha Pritam Durai, First of all this approach is not good as it changes the Root node means Header CDS is already changed same primary key will be repeated.
    As a workaround duplicate entry by implementing get_entitySet method of DPC_EXT, or if you are using RAP you can use Custom Query implementation.

  • Hi Sascha,

    We have a similar requirement in the application we are developing.

    The Associated view has a 0:* cardinality with the main View.

    I created Views similar to the one you had mentioned and tested the same.

    But, I found Duplicate entries for the Sales Orders when there are multiple items with same product.

    Please find below the code and screen shot.

    Could you please let us know if you were able to achieve the same?

    If so, kindly let me know the steps.

    define view ZC_SO_HEAD
      as select from I_SalesDocument as head
      association [0..*] to ZC_SO_ITEM as _Items   on _Items.SalesDocument = $projection.SalesDocument
      association [0..1] to ZC_SO_ITEM as _VHItems on _VHItems.SalesDocument = $projection.SalesDocument
          @ObjectModel.association.type:  [ #TO_COMPOSITION_CHILD ]
          @UI.selectionField: [{ element: '_Items.Material', position : 4 }]

  • After some further investigations i figured out that even the generated annotations in the service are correct. So i think this is something UI5-related, but im clueless how to fix this?

    <Annotation Term="UI.SelectionFields">   

Related questions

3 Answers

  • Best Answer
    Posted on Feb 22, 2019 at 11:09 PM

    Hi Sascha Weidlich,

    When I was checking your scenario, I found the below two things:

    1. SAP UI5 doesn't support searching the associations of cardinality 1..* it only supports 1..1. So you cannot check the items but we can check the sales orders based on the business partner country (1..1) like the example given in the help.

    2. So I went a head and tested the odata service directly by sending the filter for the items. But that returned an error.

    Left hand expression of memberaccess operator has wrong cardinality (to many not allowed)

    So i guess only 1..1 cardinality search is supported.



    capture.jpg (166.1 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 09, 2019 at 04:25 PM

    Hi Sascha, I was wondering about the results of your "sneaky" workaround ;) are you using CDS based oData? Does the filtering work?

    Best regards

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 19, 2020 at 02:18 AM

    Martin Sommer Susmitha Pritam Durai Sascha Weidlich Sunil Kumar Maurya

    You can use the below blog as reference to do this using virtual elements

    Or you could use table function to concatenate all the searchable fields into one line using string_aggr function and use "Contains" filter to search from the UI.


    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.