cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
barlowse
Advocate V
Advocate V

Add the ability to CDS Views - to filter by a parameter

Being able to use Views defined on the CDS entities is great for Power Apps, however, you still have to fetch all your rows and use filtering within the app to limit the data presented to the user. I would like to be able to pass a parameter to the CDS view in order to limit the rows fetched from the server.

3 ACCEPTED SOLUTIONS

Accepted Solutions

Hi @barlowse,

It is not possible out-of-the-box to have a dynamics filter in the entity list page (clicking the entity from the sitemap). For what exact scenario are you trying to have a dynamics filter? There are probably a few workarounds, for instance:

  • If you want to dynamics filter a view for a lookup field that it's possible with the addCustomFilter function

 

formContext.getControl(arg).addCustomFilter(filter, entityLogicaName)

 

  • For a subgrid on a form, then you can dynamics filter based on the related record
  • Or you can filter a subgrid on a form with SetParameter but it is an unsupported customization
  • You can have some pre-build views and toggle them as need be

Hope this helps

 

 

View solution in original post

EricRegnier
Super User
Super User

Hi @barlowse, thanks for clarifying. Since you're using canvas apps, options are:

  1. custom views but since you have lots of values it doesn't scale well like you mentioned
  2. apply the filtering directly in you canvas app with the filter expression, but you'll need to find a way to determine what that value (i.e. "Record 1") is. Would it be possible determine in the app and store value in a variable to reference in the other places?

View solution in original post

barlowse
Advocate V
Advocate V

Filtering is what used with the views, so its working. Also I added an Idea here https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Make-CDS-Views-accept-parameters/idi-p/525667

for consideration.

View solution in original post

10 REPLIES 10
SeanHenderson
Power Participant
Power Participant

You can customize your view to filter down to specific records. The filter is found in the bottom right of the view creator. 

 

Annotation 2019-12-16 105547.png

 

---
Please hit the "Accept as Solution" button if my post answered your question! If my post was helpful please consider giving it a "Thumbs Up."

Yes - the filtering is available - but it is a static filter - I am looking for a dynamic filter - where I can pass a variable from a Pwer App to the View.

Somebody, I need to same. I need to have the possibility to add a variable name. So that I can pass a value from the powerapps selection to the view. Thanks  

gdavenport
Advocate I
Advocate I

This feature would be extremely helpful

Hi @barlowse,

It is not possible out-of-the-box to have a dynamics filter in the entity list page (clicking the entity from the sitemap). For what exact scenario are you trying to have a dynamics filter? There are probably a few workarounds, for instance:

  • If you want to dynamics filter a view for a lookup field that it's possible with the addCustomFilter function

 

formContext.getControl(arg).addCustomFilter(filter, entityLogicaName)

 

  • For a subgrid on a form, then you can dynamics filter based on the related record
  • Or you can filter a subgrid on a form with SetParameter but it is an unsupported customization
  • You can have some pre-build views and toggle them as need be

Hope this helps

 

 

barlowse
Advocate V
Advocate V

Thanks for the reply Eric. I am building canvas apps on custom cds tables.
I guess to put it simply, I am looking for something like a stored procedure in SQL that I can pass a variable piece of data to and have the server do all of the filtering. Using custom views on the cds table will only get me so far, because it has to be a known value. The best workaround I have been able to do is, to use a static field that I populate with a value for example "Record 1", and then build my view using this field in the filter. However if this field has hundreds of different values - I have to build that many custom views. Which is not ideal. 
Power Automate could preform the feat for me, but I have not had positive experiences using a flow in a canvas app and the time it takes to return results has not been less than acceptable.

EricRegnier
Super User
Super User

Hi @barlowse, thanks for clarifying. Since you're using canvas apps, options are:

  1. custom views but since you have lots of values it doesn't scale well like you mentioned
  2. apply the filtering directly in you canvas app with the filter expression, but you'll need to find a way to determine what that value (i.e. "Record 1") is. Would it be possible determine in the app and store value in a variable to reference in the other places?
Fubar
Solution Sage
Solution Sage

Think Filter is the only method provided.

 

Filter('Contacts', _accountid_value = GUID("record_guid"))

barlowse
Advocate V
Advocate V

Filtering is what used with the views, so its working. Also I added an Idea here https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Make-CDS-Views-accept-parameters/idi-p/525667

for consideration.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Users online (1,838)