28 Kasım 2013 Perşembe

AXAPTA - Drop-down to table's container field at form

public void dropFile(str _FileName)
{
    BinData p = new BinData();
    ;
    super(_FileName);
    p.loadFile(_FileName);
    PRTSecondHandTractorStock.Picture = p.getData();
    element.redraw();
}

21 Kasım 2013 Perşembe

AXAPTA - Make a table field works cross-company


I learned this way from a forum . You have to just create a relation like up and care about extended data type of related fields. After that you won't need a custom lookup or supress validate method at forms. It works at AX 2009, I had no change to test with 2012.

AXAP - Cross company lookup

public void lookup(FormControl _formControl, str _filterStr)
{

      CustTable   custTable;    
      Query                   Query  = new Query();
      QueryBuildDataSource    qbds;
      SysTableLookup          SysTableLookup  =      
            SysTableLookup::newParameters(TableNum(CustTable), _formControl);
    ;
    super(_formcontrol,_filterstr);

    Query.allowCrossCompany(true);      
    Query.addCompanyRange(myTable.Company);
    qbds           = Query.addDataSource(TableNum(CustTable));
    SysTableLookup.addLookupfield(FieldNum(CustTable, AccountNum), true);      

    SysTableLookup.addLookupfield(FieldNum(CustTable, Name));
    SysTableLookup.parmQuery(Query)

    SysTableLookup.performFormLookup();
}


Don't forget to supress control's validate method!..

18 Kasım 2013 Pazartesi

AXAPTA - Skip some combobox enum items

I found the solution from a forum:

This code part should write after control's Enter methods super keyword:

    this.delete(enum2str(DTSSHOperationLineType::Part));
    this.delete(enum2str(DTSSHOperationLineType::ExternalPart));


Don't forget to set AutoDataGroup = No if control is under a parent datagroup.

14 Kasım 2013 Perşembe

AXAPTA - fast search with grid

Do not use find method for this, it works so slow with big tables. This's the way which Axapta uses with it's own forms:
 element.args().lookupField(fieldnum(SMAServiceOrderTable, ServiceOrderId));
element.args().lookupValue(_myServiceOrderId);
SMAServiceOrderTable_ds.executeQuery();

5 Kasım 2013 Salı

AXAPTA - Password field with tables

I followed up Greg on Dynamics AX blog when creating this page.

Firstly we have to add a container field at our table and change it's extended data type as CryptoBlob .

Edit method for our password field:

edit Password edtPassword(boolean _set = false, Password _pwd = '')
{
    CryptoBlob cryptoBlob = connull();
    ;
    if (_set)
    {
          this.Password = WinapiServer::cryptProtectData(str2cryptoblob(_pwd));
    }
    return (this.Password == connull()) ? '' : 'xxxxxxxx';
}


Method get password with X++ code:
Password getPassword()
{
    CryptoBlob cryptoBlob;
    ;
    cryptoBlob = this.Password;
    return (cryptoBlob == connull()) ? '' :
        cryptoblob2str(WinapiServer::cryptUnProtectData(cryptoBlob));
}


Method set password with X++ code:

void setPassword(Password _pwd = '')
{
    CryptoBlob cryptoBlob = connull();
    ;
    this.Password = WinapiServer::cryptProtectData(str2cryptoblob(_pwd));
}

Dot't forget PasswordStyle set to Yes of our form control.