Skip to Content
Technical Articles
Author's profile photo Prajna Parmita

Smart Field with Value Help and Hidden Filter

While working on a customer project we realized creating value help using smart field will save a lot of our time. How you can understand while going through this blog.Also, I can see many blogs have already been written on creating Value helps using smart field. But the difference here is that I needed to pass filters as parameter and hide them so that users cannot modify.

This last requirement of hiding the parameters itself took a lot of my time. So for the benefits of others decided to write this blog.

BUSINESS SCENARIO:

There was one form containing the fields similar to below screen.

On click of Sales Office one F4 value help has to  open and the values are to be filtered based on Division selected as in below screen shot.

 

SOLUTION

This can be achieved by adding smart field in the view xml file  and using annotations on the oData model metadata.

XML FILE:

<smartForm:GroupElement label=”{i18n>SalesOffice}”>

                                                            <smartField:SmartField value=”{ZSalesOff}” >

                                                            </smartField:SmartField>

                                             </smartForm:GroupElement>

 

For smart field to be editable base entity set must be updatable true.

LOCAL ANNOTATIONS:

 

OR in the code editor,

 

Till this point the steps are like that explained in Samples. Here Record Type: Common.ValueListParameterIn determines the filtering data set which is Division for our example.

This results in a value help like below screen shot,

 

Issue here is that user can modify the resultant set.

 

To avoid this and hide the filter use the below annotation on the property of entity.

 

 

I hope this will help other users to solve this quickly.

Assigned tags

      9 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Ekansh Saxena
      Ekansh Saxena

      Hi,

      I had a similar requirement and your blog was really helpful. Thanks for sharing the information.

      I would recommend to rename the blog title to something like 'Hidden Filters with SmartField Value Help' so that it's easier to find.

       

      BR, Ekansh

      Author's profile photo Prajna Parmita
      Prajna Parmita
      Blog Post Author

      Thank you for your suggestion. Modified the title as well as added few more tags.

      Best Regards

      Prajna

       

      Author's profile photo Sunil H
      Sunil H

      You can achieve through annotations in CDS views.

        @Consumption.valueHelpDefinition: [{ entity: 
                      {name: '/DMO/I_Connection_VH' , element: 'connection_id' },
                      additionalBinding: [{ localElement: 'CarrierID', element: 'carrier_id' }]
                      }]
      
      You can find more details here - https://help.sap.com/viewer/cc0c305d2fab47bd808adcad3ca7ee9d/1809BW.001/en-US/3051302c457e4c0f9a9c2c6abde12432.html
      
      
      Author's profile photo Prajna Parmita
      Prajna Parmita
      Blog Post Author

      Hello Sunil ,

      This blog is not focused on defining Value Help.This is more about passing filter and then hiding it.

      Best Regards

      Prajna

      Author's profile photo ragavie dakishna
      ragavie dakishna

      Thanks so much for the valuable information.

      I had similar to this requirement to hide the fields. It will help us to resolve it

      Author's profile photo Chandra Shekar Agrawal
      Chandra Shekar Agrawal

      Prajna Parmita , Is there any way to keep the filter bar visible all the time, By-default filter bar is hidden when we open the F4 Help, but in our use-case we want this to be visible all the time?

      Author's profile photo Prajna Parmita
      Prajna Parmita
      Blog Post Author

      Hello Shekar,

      I am not aware of any way to achieve this.

      Author's profile photo Chandra Shekar Agrawal
      Chandra Shekar Agrawal

      Hi Prajna, Thanks for the reply. I got this issue resolved using Visual Editor.

      Author's profile photo Atul Shrivastava
      Atul Shrivastava

      HI  Prajna Parmita ,

       

      Where to define division's value 10