≡ Menu




Date in Advance filter Dynamics Ax 2012

Consider we are going to build a Inquiry form, where we are applying different filter criteria’s.

One of them is date time filter. Consider this post is second part of one of my previous post. Where we created filter on Sales line.

http://tech.alirazazaidi.com/how-to-create-a-custom-filter-on-list-or-inquiry-form-in-dynamics-ax-2012/

 

For this filter add two utcdatetimeEdit control and set auto declaration to true so these control accessible in code. Set first Name is From_Date and second Name is To_Date.

Now drag and drop shippingDateConfirm field to Grid.

 

Now In DataSource Execute Query Method which we over write in previous post  add following lines

 

public void executeQuery()

{

QueryBuildRange QcustomerFilter;

QueryBuildRange ShippingDateConfirmedFileter;

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

ShippingDateConfirmedFileter = SysQuery::findOrCreateRange(SalesLine_q.datasourceTable(tableNum(SalesLine)),fieldNum(SalesLine,ShippingDateConfirmed));

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

{

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

 

}

else

{

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

}

if (to_date.dateTimeValue() !=utcdatetimenull() && from_date.dateTimeValue() !=utcdatetimenull())

{

 

ShippingDateConfirmedFileter.value(SysQuery::range(from_date.dateTimeValue(),to_date.dateTimeValue()));

}

else

{

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

}

 

//ShippingDateConfirmed

super();

}

 

 

Now run the form , It look likes

2-7-2015 10-46-13 PM

Now click on button to apply the new added filter

2-7-2015 11-00-00 PM

{ 0 comments… add one }

Leave a Comment