How to filter form based on Datetime control

Hi,

I’ve a filter fromdate and todate in my form, based on the date the form need to show the records.

pastedimage1516277190830v1.png

I tried using executequery in datasource like this:

public void executeQuery()

{

QueryBuildRange QcustomerFilter;

QueryBuildRange ShippingDateConfirmedFileter;
;

QcustomerFilter = SysQuery::findOrCreateRange(CustPackingSlipJour_q.datasourceTable(tableNum(CustPackingSlipJour)),fieldNum(CustPackingSlipJour,SalesId));

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

if (FromDate.dateValue()!=utcDateTimeNull() && ToDate!=utcDateTimeNull())

{

ShippingDateConfirmedFileter.value(SysQuery::range(fromdate.dateValue(),todate.dateValue()));

}

else

{

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

}

//ShippingDateConfirmed

super();

}

pastedimage1516277298644v2.png

I’ve error on this line and also I want to know whether it will work or not?

Thanks.

It is not dateTime field, it only date.
So you should be using dateNull()

Yes, Kranthi.

But I want my form to be empty when I open, once i gave the date it should display the records based on the filter.
How could I do that?

In the init method, try to add a range on any field that will not be empty by using sysQuery::valueEmptyString());
(Example - salesId), so that form will open empty. Clear the range after specifying the dates.

public void init()
{
DeliverydateFilter = sysQuery::valueEmptyString(CustPackingSlipJour_q.datasourceTable(tableNum(CustPackingSlipJour)),fieldNum(CustPackingSlipJour,SalesId));
super();

}

Is it right?

its showing error

The error is telling you that you’re calling a method with a wrong number of parameters. And indeed, you’re trying to call valueEmptyString() with a parameter, but it doesn’t except any. You probably meant something like addRange(…).value(SysQuery::valueEmptyString()).

CustPackingSlipJour_q.datasourceTable(tableNum(CustPackingSlipJour)).addRange(fieldNum(CustPackingSlipJour,SalesId)).value(SysQuery::valueEmptyString());

Sorry I didn’t understood, could you explain me more clear?