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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Having trouble figuring out how to bridge the disconnect between my dialog and a user defined query in X++

(0) ShareShare
ReportReport
Posted on by 2,007

I hope someone can offer some guidance to a Dynamics noob.

I have created a class that extends RunBaseBatch and have overridden the showQueryValues method so users can enter a query against the CustTrans.TransDate field, as the QueryRun of this class has the CustTrans as its data source and the TransDate field as its range. I have also overridden the dialog method as well, as I needed to add a field where a user could specify a file path (this particular code exports data for use with a non AX system.) When the dialog appears, it shows the filepath field as well as the transdate field with the Select button. However, if a user creates a query range using the select button, it does not populate the TransDate field in the dialog form. We are attempting to set the value of the query to the SysQueryRangeUtil::dayRange method and if I specify the range value in my X++ code like so:

queryBuildRange.value(SysQueryRangeUtil::dayRange(-60,0)

it will resolve the values of those dates in the field TransDate field in the dialog.

Obviously, I am missing something here. How do I pass the user defined query back to the dialog so that it will be used by my QueryRun? I have only been doing AX development for about 6 months, so I am sorry if this is a stupid question.

Hopefully I have described the problem correctly. Thanks for any guidance you can give me.

Brandt

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    Have you overridden the queryRun() method of your class to return your queryRun object?  That might be the disconnect.  Also, are you calling super() in your overridden dialog method?  There might be something in the super call that makes sure that your queryRun and the one displayed on the dialog are the same object. 

    Hopefully it's one of these two, but if it's not let me know and we can try and work it out further.

    -Justin

  • Verified answer
    Brandt Fundak Profile Picture
    2,007 on at

    Justin,

    The problem was with the QueryRun and it was only dumb luck that I found out what the problem was.

    My original code was this:

    Query                      query;

    QueryRun                   queryRun;

    QueryBuildDataSource       qbd;

    QueryBuildRange            qbr;

    ;

    query = new Query();

    qbd = query.addDataSource(tablenum(CustTrans));

    qbr = qbd.addRange(fieldnum(CustTrans,TransDate));

    queryRun = new QueryRun(query);

    What I didn't realize at the time is that if I assign the range to a variable, that X++ is going to expect me to provide the value. If I don't set it, the user defined query works as expected. It's quite the idiosyncracy, and one I won't forget.

    Thanks for your help.

    Brandt

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans