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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Advanced filter on a form filter one datasource and reset another datasource

(0) ShareShare
ReportReport
Posted on by 117
Hi
 
The customer requirement for the form is: 2 Fast tabs with independent grid and independent datasource, so two datasources.
 
The form pattern is "Simple Details w/Fast Tabs" - Not sure if there is a more correct pattern, but so far this is the only pattern that I could get working without BP errors / warnings based on the customer requirements.
 
As mentioned, there is 2 tabs, both have 'Custom' as pattern, each have a grid which is connected to a datasource, and a field group is used to display the data in the grid
 
There is no relations between the two tables and there will not be any interaction between the two grids.
 
The form is called from another form so in the init method, I get the passed record in the args().record() method, i store the values in in parmXXX() methods.
then in executeQuery() I have something like this:
 
SysQuery::findOrCreateRange(this.queryBuildDataSource(),fieldNum(TableA, FieldA)).value(element.parmXXX());
SysQuery::findOrCreateRange(this.queryBuildDataSource(),fieldNum(TableA,FieldB)).value(element.parmYYYY());
 
before the super call, so in general nothing special.
 
When the form is launched, the correct data is displayed.
 
When the user activate the Advanced filter on the form (Ctrl+f3) , the pre-filled values is in the filter form is from the upper datasource, which is what is the requirement, if the user then press Apply, with or without any changes, then the data in both datasources is refreshed. The data in the upper grid is refreshed with the values form the filter, the data in the lower grid has all values in the ranges reset - which mean that the grid shows all records form the datasource disregarding the values that is set in the executeQuery() method.
 
I have set the datasource of the design to Datasource_one, on the Main tab the datasource is Datasource_one, on the tab that holds the upper grid the datasource is Datasource_one and then on the tab that contains the the second grid I have Datasource_two - and I have tried with no datasource on any of the tabs.
 
In the perfect world, I would like to have 2 different Filters, but I do not think that it's possible.
Second best is that the filter only works on one of the datasources and leave the second as it is.
 
What have I missed?
 
Thanks
 
Kind regards
Steen

 
Categories:
I have the same question (0)
  • Martin Dráb Profile Picture
    237,406 Most Valuable Professional on at
    Advanced filter on a form filter one datasource and reset another datasource
    You mentioned a single executeQuery() method. Does the other data source have similar code in executeQuery() too (with different table and field names)? What did you find when you debugged the code?
     
    It's possible that the framework doesn't support what you want. It's common for forms to show several grids, but they're normally related to a common parent. For example, the Simple Details pattern is supposed to show details of a particular entity, e.g. a single customer, and there may be grids with related records related to this customer. Nevertheless I'm pretty sure we can find a solution.
     
    By the way, I would use Toolbar and List subpattern for the tab pages.
  • Martin Dráb Profile Picture
    237,406 Most Valuable Professional on at
    Advanced filter on a form filter one datasource and reset another datasource
    I quickly built a form like that - and it works fine for me. I can set filters for either data source and it doesn't influence the other.
     
    If you wish, I can share it with you, so you can check if it works in your environment too and then compare your form with mine.
  • Suggested answer
    steen.rabol Profile Picture
    117 on at
    Advanced filter on a form filter one datasource and reset another datasource
    Yes, the second datasource have a executequery() override for the table that is related to the datasource
     
    when I debugged, I saw that the parmXX() was called in executeQuery(), but the range still got cleared by the 'Apply'
     
    What I have found that seems to be working is that in the init() mehod, I find or create the ranges, then:
     
    myRange.status(RangeStatus::Locked);
     
    and then fill the the values like myRange.value(element.parmXXX()); in executeQuery()
     
    I agree that getting two table or two filter's, but that was just the 'perfect' solution in this case - anyway, the lock property seems to do the trick.
     
    Thanks for the tip with the pattern for the TabPage!
     
     

     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 779 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 670 Super User 2025 Season 2

#3
CU05031448-0 Profile Picture

CU05031448-0 520

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans