AX – D365FO – Clear a value of a previously query set filter

If you have done a query in a form and you you want to clean previouslu query filter you have to follo w this code

public void executeQuery()

{

   // Get the filter value from the filter control.

   date firstYearOfMonth;
   str monthStr;
   str yearStr;
   MonthsOfYear monthEnum;
   int monthEnumToInt;
   TransDate tmpDate;
   TransDate dateInMonth;
   TransDate firstDateOfMonth;
   TransDate endDateOfMonth;
   QueryBuildDataSource ds;
   monthStr = MonthsList.valueStr();
   yearStr = YearsList.valueStr();
   ds = this.query().dataSourceTable(tablenum(ERAWriteOffCalculation));

   if (yearStr != "")
   {
       monthEnum = str2enum(monthEnum,monthStr);
       monthEnumToInt = enum2int(monthEnum);
       tmpDate = str2Date("15/" + int2str(monthEnumToInt) + "/" + yearStr, 123);
       dateInMonth=tmpDate;
       firstDateOfMonth = DateStartMth(dateInMonth);
       dateInMonth=tmpDate;
       endDateOfMonth= endmth(dateInMonth);
        ds.addRange(fieldNum(ERAWriteOffCalculation, calcdate)).value(queryRange(firstDateOfMonth, endDateOfMonth));

   }
   else
   {
       ds.clearRange(fieldNum(ERAWriteOffCalculation,calcdate)); //This code cear previously set filters
   }
   super();
}

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...