cancel
Showing results for 
Search instead for 
Did you mean: 

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

abranjan
Active Participant
0 Kudos

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

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi abhishek.ranjan5,

Could you please share what you have done so far w.r.t. Context-Dependent Value Help?

It would help us in order to determine what is wrong with the project.

If you could also share a prototype on github, maybe we could even propose changes on the code so it works as you expect.

Best regards,
Ivan

View Entire Topic
Subramaniyam
Explorer
0 Kudos

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