Selasa, 07 April 2020

Show Active bank account

In Ax2012 there is VendBankAccount table.
there's one field shown on our screen that gives us information the state of bank account. Active or inactive.
unfortunately this information made by a method.

so how to make a query to filter or specify the record, active or inactive?
Activedate and Expiredate in VendBankAccount, both made by UTCDateTime
Bank account state made by method.

i guess for some programmer it is gonna be tricky.

Working with UTCDateTime is need call another method dan extended data type especially to get current date and time.

this is my example method how to filter/specify whether the Bank Account is active or expired.
i applied this method when user Lookup Bank Account.

static void lookupVendBankAccountId(FormStringControl _formControl, VendAccount _vendAccount)
{
    SysTableLookup          sysTableLookup;
    Query                   query;
    QueryBuildDataSource    qbds;
    
    //Working with UTCDateTime
    date                    currentdate;
    TimeOfDay               currenttime;
    utcDateTime             rangedate;
    //macro for define Expire date condition
    #localmacro.ExpiryDateCriteria "((ExpiryDate == \%1) || (ExpiryDate > \%2))" #endmacro
    #localmacro.ActiveDateCriteria "(ActiveDate <= \%1)" #endmacro
    
    
    ;
    
    //Working With UTCDatetime
    currentdate = today();
    currenttime = timeNow();
    rangedate = DateTimeUtil::newDateTime(currentdate,currenttime,DateTimeUtil::getUserPreferredTimeZone());

    sysTableLookup = SysTableLookup::newParameters(tableNum(VendBankAccount), _formControl);

    query = new Query();
    qbds = query.addDataSource(tableNum(VendBankAccount));
    qbds.addRange(fieldNum(VendBankAccount, VendAccount)).value(SysQuery::value(_vendAccount));
    //specify the active or inactive bank account 
    qbds.addRange(fieldNum(VendBankAccount, ActiveDate)).value(strFmt(#ExpiryDateCriteria, date2StrXpp(dateNull()) , DateTimeUtil::toStr(rangedate)));
    
    
    
    sysTableLookup.addLookupfield(fieldNum(VendBankAccount, AccountId));
    sysTableLookup.addLookupfield(fieldNum(VendBankAccount, Name));
    sysTableLookup.addLookupfield(fieldNum(VendBankAccount, AccountNum));
    sysTableLookup.addLookupfield(fieldNum(VendBankAccount, ContactPerson));
    sysTableLookup.addLookupfield(fieldNum(VendBankAccount, VendAccount));

    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

  


  

Tidak ada komentar:

Posting Komentar

Erorr CS1963 - An expression tree may not contain a dynamic operation.

Kali ini saya mendapatkan erorr dengan code CS1963, padahal sebelumnya saya sudah mendefinisikan 'var item in Model' di @foreach(var...