cancel
Showing results for 
Search instead for 
Did you mean: 

CAP annotation @Common.valuelistwithfixedvalues with Flexible Programming Model not working

08-31-2023 2:43 PM
abranjan Active Participant
2321 views 2 comments
0 Likes
SAP Managed Tags
Subscribe

Hi Everyone,

I am creating a CAP application with Filter Bar and Smart table control using Flexible programming model and cds annotations.

Goal: Based on the selection of one drop down value I want to restrict few values of another drop down from Filter Bar. (I want if-else sort of conditional flexibility on the value selection from 1st drop down -- so that other drop down values can be manipulated) -- Using Annotations

Flexible Programming Model:
I have tried out FPM with CAP cds annotations. I specifically wanted this below feature to work out for me:

4) Context-Dependent Value Help - https://sapui5.hana.ondemand.com/test-resources/sap/fe/core/fpmExplorer/index.html#/advancedFeatures...

but when I put context and conditions like SAP has maintained here in above guide. I am not able to make it work.

Is there any suggested way to approach this??
Or if anyone knows how to properly use context and conditions with CAP cds annotations?

It would be a great help!!

Thanks in advance!!
Abhijeet

0 Likes

Accepted Solutions (0)

Answers (1)

Answers (1)

Subramaniyam
Explorer
0 Likes

Hi @abranjan ,

I could'nt find the solution through annotations, but via different route. 

You will have to cache the selected value from the drop down locally in the runtime  and use it as filter in the following manner.

srv.on('READ','Myentity',async req=>{
      

    if(req.query.SELECT !== undefined){
      const condtionLiteral =`DropDownFieldName='SelectedDropDownFieldValue'`

     //instantiate the cxn parser object
      const parser= cds.parse;
      // parse cxn : resultant =>   {xpr:[ {ref:['DropDownFieldName']}, '=', {val:'SelectedDropDownFieldValue'} ]}
      const cxnObject = parser.expr(condtionLiteral);
      const cxnArray = [...cxnObject.xpr];
      req.query.SELECT.where = cxnArray;
    }

    const data = await srv.run(req.query);
    return data 
})

Please also have a look at this documentation of CXN - CXN-Expression Notation  .Let me know if this works for you.

Thank you 

Regards

Subramaniyam N