Skip to Content
Author's profile photo Pradeep Kumar N

How to hide show dropdown option of OWL UI dynamically

Here i would describe how to hide the defaultset option (show dropdown option) of the OWL UI/Query dynamically using ABSL resue library code.

additionally also will describe how to pass value to Query parameter dynamically using ABSL reuse library.

Created Business Object:
VehicleBO.PNG

and generated UIs including OWL.

OWL sample data:
OWL.PNG

Here there is a defaultset dropdown option “All Vehicles” , this displays all the vehicles data.

1) How to pass value to query parameter dynamically using ABSL reuse library:

example: scenario is to have a defaultset option called “Current year Mfg” to display the vehicles which displays vehicles with ManufacturedYear from current year only.

a. Created resuse library to get current year:

ReuseLibraryYear.PNG

b. Added query parameter ManufacturedYear in the OWL:
QueryParameterYear.PNG

c.Created anothter defaultset “Current year Mfg” with query parameter “ManufacturedYear” mapped to the reuse library we created in step a:

QueryParameter.PNG

when we preview we will see the new defaultset option “Current year Mfg” with data filtered on ManufacturedYear for the current year:

NewDefaultSet.PNG

so now we have two defaultset options in the Show dropdown of the OWL query:

“All Vehicles” to display all the vehicles
and

“Current year Mfg” to display vehicles from the current year

2) How to hide a defaultset option dynamically using ABSL reuse library:

example: scenario is to display the defaultset option “All vehicles” for only my user (User = ABC) and hide it for all other users

a.Created reuse library “GetLoggedInUser” to return current logged in user:
CurrentUser.PNG

b.Created a datamodel element to map to the reuse library:

Datamodelelement.PNG

c.Created field transformation to map the datamodel element to the reuse library:

FieldTransformation.PNG

d. Created “Calcuated Rule” for the visibleField property for the defaultset “All Vehicles” :

DefaultSetVisible.PNG

e.Calculated Rule script to display defaultset option “All Vehicles” only for current user:UIScript.png

f.In the “DefaultSet Mapping” to include both the defaultsets and also change the “Default DefaultSet” to “CurrentYearMfg”

Deaultset.PNG

Result:

With this change only user “ABC” can see the defaultset option “All Vehicles” all other users won’t see it.

with user “ABC” logged in, user can see both the defaultset options:

ABCUser.png

and all other users will see only one defaultset option “Current year Mfg”:OtherUsers.PNG

Some of the learnings from this content are:
ABSL Reuse library,

Using reuse library in UI,

UI Script,

Dynamically controlling visibility from UI,

Query Defaultset,
Field transformation,

Get current user,

Get current year

etc.

Thanks, Pradeep.

Assigned Tags

      11 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Navin Kandasamy
      Navin Kandasamy

      Hi Pradeep,

      Very useful blog.Thanks for sharing your knowledge.

      Author's profile photo Horst Schaude
      Horst Schaude

      Hello,

      You should keep in mind that you need to mark the checkbox "UI Designer" for the Reuse Library Functions if you want to use them in the query parameter mapping. 😉

      Bye,

          Horst

      Author's profile photo Former Member
      Former Member

      Thanks Pradeep Kumar N & Horst Schaude very much

       

      Pradeep's blog is very useful and I have achieved my requirement of the parameter mapping, especially the content of Horst is very critical for me ,because I encountered the problem that I couldn't choose my namespaces before I marked the the checkbox “UI Designer”.

       

      Now, I have a problem: Can I set default values for advanced search dynamicly?

      Looking forword to your reply!

      Author's profile photo Horst Schaude
      Horst Schaude

       

      Hello Baoxiang,

      The determination of the current year is a dynamically setting of the default value for the advanced search. 🙂

      Maybe you need to elaborate your requirement a little bit.

      Bye,
      .    Horst

      Author's profile photo Former Member
      Former Member

      Hello Horst,

      OK, Now I have created a query for my Custom BO and drag some fields in OWL as advanced search fields in UI designer

      So I want to limit the OWL list results by set default values for advanced search,for example,I set the advanced search field "Year" as "2017",and I will only see the "2017" records when I initialize the OWL view

      My ultimate goal is to restrict query results and I also asked a question about Standard BO search

      https://answers.sap.com/questions/202371/index.html

      Wish you can give me some advices to solve my problems

      Thanks

      Baoxiang

      Author's profile photo Horst Schaude
      Horst Schaude

       

      Hello Baoxiang,

      "My ultimate goal is to restrict query results " and "I set the advanced search field “Year” as “2017”,and I will only see the “2017” records"

      This means you did it already?

      Bye,
      .    Horst

      Author's profile photo Former Member
      Former Member

      Hi Horst,

      I didn't achieve it, “I set the advanced search field “Year” as “2017”,and I will only see the “2017” records” is what I want to accomplish, but I don't know how to do it?

      Baoxiang

      Author's profile photo Horst Schaude
      Horst Schaude

       

      Hello Baoxiang,

      If you follow the steps described above by Pradeep you will achieve this.

      Important is the Customer Reuse Library, which returns the current year and the new Default Set with the mapping of the "Transformation Definition" to the "Customer Reuse Library".

      HTH,
      .    Horst

      Author's profile photo Former Member
      Former Member

      Hi Horst

      Yeah,I achieved it by using Customer Reuse Librar,It is useful and no problems.

      But now ,I want to filter standard BO data,I think if there have some BADI(enhance options) to achieve it or assign default values to the standard BO query fields before I get into OWL view

      Baoxiang

      Author's profile photo Horst Schaude
      Horst Schaude

      Hello Benny,

      As mentioned in the other question: This is unfortunately not possible. 🙁

      Bye,
      .   Horst

      Author's profile photo Sandico Mark
      Sandico Mark

       

      In this scenario, if I was logged in as user 'DEF', I would not see the dropdown for 'All Vehicles', thus hiding any vehicles except those in the current year (2016).

      If I were to use the filter/search function and search for a vehicle based on a field that will give me a non-2016 vehicle, say colour = 'blue', will the search results display the non-2016 vehicles then?

      Trying to make sure that even the filter/search function respects the business rule of non-ABC user not being able to see any non-current year vehicles.