• Skip to main content
  • Skip to primary sidebar
  • Home
  • About
  • Recommended Readings
    • 2022 Book Reading
    • 2023 Recommended Readings
    • Book Reading 2024
    • Book Reading 2025
  • Supply Chain Management Guide
  • PKM
  • Microsoft Excel

Ali Raza Zaidi

A practitioner’s musings on Dynamics 365 Finance and Operations

How to create a custom filter on list or inquiry form in Dynamics AX 2012

February 4, 2015 by alirazazaidi

During development we have to create custom inquiry forms. Or Form where we can  search and filter records on different criteria.

Consider a scenario, where we have to build custom inquiry form for all saleline. In this inquiry or custom list form, we can filter on records on date, customer and amount or discount.

Lets do this,

 

Create a form with name custom Sales


From expend its designs and right click on design to open its property window

 

Design property

 

From property window set its design style to simplelist

 


Simple list

 

Now add new data source on form, and sets create and edit property to no, Because we did not want to insert , update and delete operation  on this form.

 

Drop down

 

 

Now drag and drop following fields form  data source to grid.

 

ItemId,CustNumber,SalesQty,SalesPrice,

 

selected fields

 

Now right click on grid and set its datasource to salesline.

Datasource for grid

Now run the form its look like similar

 

Grid with data

Now above grid, add  group control and set its column property to 2, also set its visible property to true.

Add String Edit control, and button here.

Right click on String Edit control and set its auto delecaration to true, so we can access this control in x++. Set its name as “txtCustomerNum”. And set its lookup property to always.

 

 

ControlName

 

 

lookup always

 

Now we are going to create Unbound control with lookup,

Right lock on methods under stringEditcontrol and add lookup method.

Add following code to fill the lookup to customer and Name which belongs to current legal entity.

public void lookup()

{

Query query = new Query();

QueryBuildDataSource queryBuildDataSource, qbds, dsView;

QueryBuildRange queryBuildRange;

 

SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(CustTable), this);

 

sysTableLookup.addLookupField(fieldNum(CustTable, AccountNum));

sysTableLookup.addLookupField(fieldNum(CustTable, Party), false);

 

queryBuildDataSource = query.addDataSource(tableNum(CustTable));

 

qbds = queryBuildDataSource.addDataSource(tableNum(DirPartyTable));

qbds.joinMode(JoinMode::InnerJoin);

qbds.addLink(fieldNum(CustTable, Party), fieldNum(DirPartyTable, RecId));

 

dsView = qbds.addDataSource(tableNum(DirPartyPostalAddressView));

dsView.joinMode(JoinMode::InnerJoin);

dsView.addLink(fieldNum(DirPartyTable, RecId), fieldNum(DirPartyPostalAddressView, Party));

 

 

sysTableLookup.parmQuery(query);

 

sysTableLookup.performFormLookup();

 

 

}

 

Now run the form lets see the how behave the lookup control.

Lookupdisplay

Man its working. Now check that selected value from this textbox is accessible, then we move to filter the records

Add Click event/ method on button we just added with this string edit button.

 

And right following code.

void clicked()

{

super();

info(  txtCustomerNumber.text());

}

 

 

Now run the form, select customer and click on button.

dd

 

 

Now right click on Salesline datasource and over rights its execute Query method.

And add following lines to filter it.

public void executeQuery()

{

QueryBuildRange QcustomerFilter;

QcustomerFilter = SysQuery::findOrCreateRange(SalesLine_q.datasourceTable(tableNum(SalesLine)),fieldNum(SalesLine,CustAccount));

if (txtCustomerNumber.text()!=””)

{

QcustomerFilter.value(queryValue(txtCustomerNumber.text()));

 

}

else

{

QcustomerFilter.value(SysQuery::valueUnlimited());

}

super();

}

 

In button click even add this line code

void clicked()

{

super();

SalesLine_ds.executeQuery();

 

}

 

 

 

Now run the form, select the customer and click on button, you will find the filter records on form

Column

 

 

In next post will add more filters to this form.

 

Filed Under: Dynamics AX 2012, Dynamics Ax 2012 Forms, Tips and tricks Tagged With: Dynamics Ax 2012

Primary Sidebar

About

I am Dynamics AX/365 Finance and Operations consultant with years of implementation experience. I has helped several businesses implement and succeed with Dynamics AX/365 Finance and Operations. The goal of this website is to share insights, tips, and tricks to help end users and IT professionals.

Legal

Content published on this website are opinions, insights, tips, and tricks we have gained from years of Dynamics consulting and may not represent the opinions or views of any current or past employer. Any changes to an ERP system should be thoroughly tested before implementation.

Categories

  • Accounts Payable (2)
  • Advance Warehouse (2)
  • Asset Management (3)
  • Azure Functions (1)
  • Books (6)
  • Certification Guide (3)
  • Customization Tips for D365 for Finance and Operations (62)
  • D365OF (59)
  • Data Management (1)
  • database restore (1)
  • Dynamics 365 (58)
  • Dynamics 365 for finance and operations (135)
  • Dynamics 365 for Operations (165)
  • Dynamics AX (AX 7) (134)
  • Dynamics AX 2012 (274)
  • Dynamics Ax 2012 Forms (13)
  • Dynamics Ax 2012 functional side (16)
  • Dynamics Ax 2012 Reporting SSRS Reports. (31)
  • Dynamics Ax 2012 Technical Side (52)
  • Dynamics Ax 7 (65)
  • Exam MB-330: Microsoft Dynamics 365 Supply Chain Management (7)
  • Excel Addin (1)
  • Favorites (12)
  • Financial Modules (6)
  • Functional (8)
  • Implementations (1)
  • Lifecycle Services (1)
  • Logseq (4)
  • Management Reporter (1)
  • Microsoft Excel (4)
  • MS Dynamics Ax 7 (64)
  • MVP summit (1)
  • MVP summit 2016 (1)
  • New Dynamics Ax (19)
  • Non Defined (9)
  • Note taking Apps (2)
  • Obsidian (3)
  • Personal Knowledge Management (2)
  • PKM (13)
  • Power Platform (6)
  • Procurement (5)
  • procurement and sourcing (5)
  • Product Information Management (4)
  • Product Management (6)
  • Production Control D365 for Finance and Operations (10)
  • Sale Order Process (10)
  • Sale Order Processing (9)
  • Sales and Distribution (5)
  • Soft Skill (1)
  • Supply Chain Management D365 F&O (3)
  • Tips and tricks (278)
  • Uncategorized (165)
  • Upgrade (1)
  • Web Cast (7)
  • White papers (4)
  • X++ (7)

Copyright © 2025 · Magazine Pro On Genesis Framework · WordPress · Log in