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

How to set up automatically the SysQueryForm by code at form start?

(0) ShareShare
ReportReport
Posted on by

I have been asked to set up the "Advanced filter or sort" (the one in the OPTIONS section of every form, in the AOT it's called SysQueryForm) for a certain form that I have created.

(please, this is what I have been precisely asked to do, they won't accept a similar alternative)

When the user is using my form and wishes to go to OPTIONS->"Advanced filter or sort"   he/she should find the filter already set up with some fields.

 I should add a series of blank filters table-->field and the user should only select the value:

It should be something like this, but I have to manually select the tables and fields that appear for the user:

1.png

This is actually from my form, I don't know why these two fields appear here, I just noticed that they belong to one index  of the RouteVersion, is there a way to remove them and add the ones i want?

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    236,316 Most Valuable Professional on at
    RE: How to set up automatically the SysQueryForm by code at form start?

    What you really need to do is adding a query range to the datasource; than it will become visible in SysQueryForm and all other places (SysQueryForm is not the only way how you can see and modify filters).

    For example, you can put code like this to init() method of the DS: this.queryBuildDataSource().addRange(fieldNum(Table, Field)).

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: How to set up automatically the SysQueryForm by code at form start?

    Your screenshot doesn't work, could you try to upload it again?

    Anyway, you can add predefined ranges in the form's query in code. These ranges will also show up in the filters. You can define ranges without values, or ranges with fixed values.

    In the init method of the form data source, add following code:

    public void init()
            {
                super();
    
    
                // Range with fixed value
                this.queryBuildDataSource().addRange(fieldNum(MyTable, MyField)).value("MyValue");
    
                // Range with no value
                this.queryBuildDataSource().addRange(fieldNum(MyTable, MyField2));
            }

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,157

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 674 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans