cancel
Showing results for 
Search instead for 
Did you mean: 

Setting a Default Value for Filter in Fiori Elements using Annotations

pghoshroy
Participant
6,695

Hi experts....

I have developed a simple app using Fiori Elements to show products for a particular store. For the app to work the user needs to provide the store or select the store.

As you can see it's a fixed value drop down list that I was able to achieve using the following annotation.

So now my next assignment is to assign a default value to it e.g. store name "ABC"; to save the user time from selecting it. However, the default value must be one from the existing list of stores (i.e. . ZPOS_C_STORE_NAME)

Can anyone advise how I can achieve this using Annotations or by App extension?

So basically, when the app loads; then it should look something like this before I press GO:

The App just uses 2 CDS views one for the complete list of Stores and Products/Material and CDS2 that provides a list of stores (which I am using for the Drop-Down List).

Regards,

Pablo Ghosh Roy

View Entire Topic
Bernard
Participant

Hi,

The annotation below should do the trick.

<Annotation Term="Common.FilterDefaultValue" String="ABC"/>
pghoshroy
Participant
0 Kudos

Hi Bernard,

Thank you so much for your response. Can you please advise; how can I retrieve the value "ABC" in this case without hardcoding the value "ABC"?

Do I need to create another CDS View that would only contain the default value "ABC" as a single row and associate it to the main CDS Service?

Regards,

Pablo Ghosh Roy

Bernard
Participant
0 Kudos

It may depend on the store default you want to display.

Is the default store any random valid store?

Or is the store to be displayed a store that is contextually relevant to the user?

(If the latter there is a default value personalisation option)

Just not sure what your intention is here.

pghoshroy
Participant
0 Kudos

Hi Bernard,

Thank you again for your response and I apologise if you found my question vague.

The scenario is .... Users will be assigned to a particular store. So, when a user logs onto the app; I must default the value of the store to which the user is assigned to; however, they do have the option to change and see the data for other stores.

e.g. User A, B, C are assigned to Stores 1,2,3. So, when User A opens the app; they can see the value 1 defaulted in the Store; similarly, B will see the value 2 as the store and C will see 3.

Now I have a single CDS view that lists all the materials across all stores. "C_MAT_STOCK_BY_PLANT_CDS"

Then I have another CDS that has the list of store and store names (which forms the Value List). "C_STORE_NAME"

Now I am trying to find a way to default the Store in the Value List/Drop Down. (The relation between the store and user is maintained in a table).

Regards,

Pablo Ghosh Roy

Bernard
Participant

You could add an association to your OData service (Consumer CDS view) where you have the user-to-store mapping.

You could then do a Fiori App extension, retrieve the store for the current user and set the relevant filter (i.e. your store filter) to the value retrieved.

pghoshroy
Participant

Thank You Bernard. Your solution/suggestion worked.

Thanks Bernard.

LN1
Participant
0 Kudos
Hi Pablo, Would you be able to share the details/steps of your solution that worked? I have a similar requirement but for a filter field that can accept multiple values. The possible values would be dynamic. It could be one value or a hundred of them. These values may come from a db table linked to the current user. Pls advise. Thanks.