web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Filtering a dataset do...
Power Apps
Unanswered

Filtering a dataset does not work?

(0) ShareShare
ReportReport
Posted on by 13

I have som issues with filtering a dataset and I'm wondering if I'm doing anything wrong. I've broken it down to something simple. Please view the code below. It only uses the default dataset with the three records which all contains the value "val" in the three columns "name", "telephone1" and "address1_city". I apply a filter to the dataset and then I do a refresh on the dataset and then I expect the updateView to get called again with the new dataset. But this does not seem to happen. Given the code below this is the output I have in my console. the updateView only runs once and does not filter my dataset.

 

I am copying @mtanguy  in here because I see on these forumn that you have some experience in this.

 

EDIT: Or is just buggy behaviour in the testharness and it would work in a D365 instance? Its a hassle to upload the solution to D365 eveytime you want to try a change.

 

Capture.PNG

 

 

 

 

 

 

init function:

 

 

public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container: HTMLDivElement) {
	console.log("init function called");
	context.mode.trackContainerResize(true);
}

 

 

 

updateView function:

 

 

public updateView(context: ComponentFramework.Context<IInputs>): void {
		console.log("updateView function called");
		
		const existingFilter = context.parameters.GridSampleData.filtering.getFilter();

		if (!existingFilter) {
			console.log("No existing filter. Setting filter...");
			context.parameters.GridSampleData.filtering.setFilter({
				filterOperator: 0,
				conditions: [{
					attributeName: "name",
					conditionOperator: 1, // NotEquals
					value: "val",
				}],
				filters: [],
			});

			context.parameters.GridSampleData.refresh();

		} else {
			console.log("Filter exists");
		}

		for(const recordId of context.parameters.GridSampleData.sortedRecordIds) {
			const record = context.parameters.GridSampleData.records[recordId];
			console.log(record.getFormattedValue("name"));
		}
	}

 

 

 

I have the same question (0)
  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @MariusSolend ,

    Could you please share more details about your Manifet.Input.xml file?

    Do you want to developer a code component for Model-Driven app for canvas app?

     

    Currently, the Refresh function under the DataSet is only available for Model-Driven app. If you are developing this code component for a canvas app, the following formula would not work:

    context.parameters.GridSampleData.refresh();

    Pease check the following article for more details:

    https://docs.microsoft.com/en-us/powerapps/developer/component-framework/reference/dataset/refresh

     

    In addition, the updateView function would only be called when any value in the property bag (defined in your Manifet.Input.xml file) has been changed. Please check if the property value has been changed after executing your filtering formula.

     

    Best regards,

  • Marius Solend Profile Picture
    13 on at

    This is for a modeldriven app. And i just run this in the test harness. I dont have a property in my manifest file. I only have a dataset called GridSampleData like this:

    <data-set name="GridSampleData" display-name-key="GridSampleData" description-key="GridSampleData" cds-data-set-options="displayCommandBar:true;displayViewSelector:true;displayQuickFindSearch:true">
    </data-set>

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 320 Most Valuable Professional

#2
11manish Profile Picture

11manish 210

#3
Valantis Profile Picture

Valantis 167

Last 30 days Overall leaderboard