bellwether
bellwether

Reputation: 27

Clear filter query before running next script

The Setup

I have a project table displaying values from a Calculated SQL data model. The table has edit buttons for each row that when clicked open a page fragment for editing the relevant project.

Because the display table is showing values from a Calculated SQL model, the edit button runs this query to load the underlying project record from the Cloud SQL source model.

// onClick edit button event handler
var calcTableIds = widget.datasource.item.projectsTableId; // Calculated SQL model
var projectsTableIds = app.datasources.projects; // Cloud SQL model

projectsTableIds.query.filters.Id._equals = calcTableIds;
projectsTableIds.load();
app.showDialog(app.pageFragments.ProjectEdit);

The Problem

The issue I'm having is that after a project record has been edited, subsequent functions I attempt to run that reference the Cloud SQL model only display results for the last edited project record.

I believe I need to run a script upon closing the project edit window that will reverse the query filter but I haven't been able to figure out a solution on my own.

FYI, the script I'm attempting to run after editing a project is the AMU Export function which should export all records from my Cloud SQL model to a spreadsheet but instead only exports the last edited record.

Upvotes: 0

Views: 88

Answers (1)

Morfinismo
Morfinismo

Reputation: 5253

As per the official documentation, you need to use the method clearFilters(). So when closing the fragment simply do:

app.datasources.THEDATASOURCE.query.clearFilters();
app.datasources.THEDATASOURCE.load();

Upvotes: 1

Related Questions