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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

plugging default range values in a query object at runtime in X++?

(0) ShareShare
ReportReport
Posted on by 427

Hello everyone,

Following a question which was quickly answered in this thread by Ievgen Miroshnikov:

https://community.dynamics.com/ax/f/33/p/275533/785314#785314

I am also trying to figure how to propose default values to the query range fields; when I override the query's prompt method and add some ranges in there to the query, they are ignored when the prompt dialog is displayed, as the default proposed ranges fields are selected from the table primary index (excluding int64 fields).

Is it possible to propose at runtime default values to appear in the range fields? When displaying the select query range form in the get staging data step, DIXF does manage to insert the values that were previously selected in the entity configuration. so AX seems to have a mechanism to plug default value, but I'm lost when tracing the code at how exactly it is performing the substitution.

Regards,

Eric

AX 2012 r3 - cu8

*This post is locked for comments

I have the same question (0)
  • Mea_ Profile Picture
    60,286 on at

    Hi Eric Lepage,

    There is no easy way. It uses pack and unpack to prompt you with previous values (again not related to DMF) .

    First of all you have AOT query where you can try to set this ranges. Then take a look at resetQuery() method on dmfDefinitionGroupExecution table maybe you can add ranges there.

  • Verified answer
    Arkadia2 Profile Picture
    427 on at

    Hello Ievgen,

    Thanks again for replying.

    I found a way, seems decent too, using QueryFilter object returned from the query object, Didn't know this feature existed. 

    In the query prompt method:

    QueryBuildDataSource qbds;
    boolean ret;
    QueryFilter qf;
    DictIndex dictIndex;
    DictTable dictTable = new DictTable(tableNum(TheTable));
    IndexId indexId;
    int indexCounter;
    int indexFieldNb;
    int queryFilterFieldCnt;
    fieldid fieldId;
    DictField dictField;

    qbds = this.query().dataSourceTable(tableNum(TheTable));
    if(qbds)
    {
        indexId = indexName2id(tableNum(TheTable), 'IndexName');
        dictIndex = new dictIndex(dictTable.id(), indexId);
        indexFieldNb = dictIndex.numberOfFields();
        if(dictIndex)
        {
            for (indexCounter = 1; indexCounter <= indexFieldNb; indexCounter++)
            {
                fieldId = dictIndex.field(indexCounter);
                dictField = new DictField(dictTable.id(), fieldId);
                if(dictField.baseType() != Types::Int64)
                {
                    queryFilterFieldCnt++;
                    switch(FieldId)
                    {
                        case fieldNum(TheTable, OneDateField):
                            qf = this.query().queryFilter(queryFilterFieldCnt);
                            if(qf)
                            {
                                qf.value(queryValue(mkDate(1,5,2016)));
                            }
                        break;
                        case fieldNum(TheTable, AnotherDateField):
                            qf = this.query().queryFilter(queryFilterFieldCnt);
                            if(qf)
                            {
                                qf.value(queryValue(mkDate(30,4,2017)));
                            }
                       break;
                 }
             }
        }
    }
    }

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 34

#2
Michel ROY Profile Picture

Michel ROY 14

#3
Jagadabi Profile Picture

Jagadabi 6

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans