Rabu, 29 April 2020

System does not support setup 'continuous' of number sequence

When we work with entries data that contain sequence number sometime we need an improvement to create in another way, a Generate perhaps.

Usually we can use the code like this :

//number sequence MRIS
    NumberSeq                       num;
;

num = NumberSeq::newGetNum(InventParameters::[method for Sequence number]);

it can be work if the continuous cekbox, in Sequence number master is false.

but fi the continuous cekbox, in Sequence number master is True, the system will give a message "System does not support setup 'continuous' of number sequence"

so you need to put ttsbegin and ttscommit on your codes :

NumberSeq                       num;
Sampletable                      sampletable;
;
ttsbegin;

num = NumberSeq::newGetNum(InventParameters::[method for Sequence number]);
sampletable.clear();
sampletable.number =  num.num();
sampletable.insert();

ttscommit;

  

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();
}

  


  

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...