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)

filtration on Display Method in Form

(0) ShareShare
ReportReport
Posted on by 54

Hi,

i have written display method and captured data on invent table (recent purchased date i.e physical date in invent trans). i am written some code for filter the date range. its not working.

please help me.

void context()
{
int selectedMenu;
real test;
formrun fr;
Args ag;
str strtext;
TransDate dateRange;
querybuilddataSource qb1, qb2;
queryrun qr;
query q = new Query();
PopupMenu menu = new PopupMenu(element.hWnd());
int a = menu.insertItem('Find');
int b = menu.insertItem('Filter');
int c = menu.insertItem('Remove Filter');
selectedMenu = menu.draw();
switch (selectedMenu)
{
case -1:
break;
case a:
ag = new args('SysformSearch');
fr = new formrun(ag);
fr.run();
fr.wait();
strtext = fr.design().controlName("FindEdit").valueStr();
info(strFmt("%1",strtext ));
dateRange = str2Date(strtext, 213);

if(strtext)

q = inventTable_ds.query();
qb1 = q.dataSourceTable(tablenum(InventTable));
qb2 = qb1.addDataSource(TableNum(InventTrans));
qb2.addLink(FieldNum(InventTable,ItemId),FieldNum(InventTrans,ItemId));
qb2.addRange(FieldNum(InventTrans,Datephysical)).value(queryrange(dateRange, dateRange));
inventTable_ds.query(Q);
inventTable_ds.executeQuery();


break;
case b:

q.dataSourceTable(tableNum(InventTrans)).addRange(FieldNum(InventTrans,DatePhysical)).value(queryrange(dateRange, today()));
inventtable_ds.executeQuery();
break;
case c :
inventtable_ds.query().dataSourceTable(Tablenum(InventTrans)).clearRanges();
inventtable_ds.executeQuery();
break;
Default:
break;
}
}

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    239,392 Most Valuable Professional on at

    I don't see what your code has to do with a display method. It seems that you're filtering by InventTrans.DatePhysical, which is a field, and you do from context(), not from any display method. By the way, you would demonstrate your point more clearly if you removed unrelated to your question, such as constructing the context menu.

    I see you're trying to queryrange() at two places  - which one "doesn't work"? Note that one of them isn't really a range, because you're using the same values for both bounds.

    Also, look into debugger to see what value you have in your dateRange variable. it might be wrong and then you can also provide a snippet with the real value to test.

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 March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 39

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans