table etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
table etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

4 Ocak 2017 Çarşamba

AXAPTA - Synchronize tables

That code works on common situation my colleauge found from web (don't know the source):

    Dictionary              dict;
    int                     idx, lastIdx, totalTables;
    TableId                 tableId;
    Application             application;
    SysOperationProgress    progress;
    StackBase               errorStack;
    ErrorTxt                errorTxt;
    ;

    application = new Application();
    dict = new Dictionary();
    totalTables = dict.tableCnt();
    progress = new SysOperationProgress();
    progress.setTotal(totalTables);
    progress.setCaption("@SYS90206");
    errorStack = new StackBase(Types::String);

    lastIdx = 3000;
    try
    {
        for (idx = lastIdx+1; idx <= totalTables; idx++)
        {
            tableId = dict.tableCnt2Id(idx);
            progress.setText(dict.tableName(tableId));

            lastIdx = idx;
            application.dbSynchronize(tableId, false, true, false);
            progress.incCount();
        }
    }
    catch (Exception::Error)
    {
        errorTxt = strFmt("Error on table: '%1' (%2) ", tableId, dict.tableName(tableId));
        errorStack.push(errorTxt);
        retry;
    }

    setPrefix("@SYS86407");
    errorTxt = errorStack.pop();
    while (errorTxt)
    {
        error(errorTxt);
        errorTxt = errorStack.pop();
    }

2 Mart 2016 Çarşamba

AXAPTA - Find a table fields label value

There are two ways to find a table field's label value:

If fields label value derived from directly fields extended data type:
 
    if (curext()=="krc" && this.RBOInventItemGroupId == "")
        ret = checkfailed(strfmt("'%1' field cannot be empty!..",
            new SysDictType(extendedTypeNum(RBORetailGroupId)).label()));

If there is a special label value dedicated at table level:

    if (curext()=="krc" && this.RBOInventItemGroupId == "")
        ret = checkfailed(strfmt("'%1'
field cannot be empty!..",
            new SysDictField(tablenum(WholeSalesCampaignGroup),
fieldnum(WholeSalesCampaignGroup,RBOInventItemGroupId)).label()));
 

27 Ağustos 2015 Perşembe

AXAPTA - Save query to a table field and restore than

I used Mirko Bonello's blog for this sample.

Create a container field at table. Mine is InventTableQuery:

void createAndSaveQueryInTable()
{
  QueryRun SysqueryRun;
  ;
  if (this.InventTableQuery)
      queryRun = new QueryRun(this.InventTableQuery);
  else
      queryRun = new QueryRun(queryStr('InventTable'));

   qrun.promptLoadLastUsedQuery(false);
   if (queryRun.prompt())
      this.InventTableQuery = queryRun.pack();
}


We used SysQueryRun instead for QueryRun and set qrun.promptLoasLastUsedQuery(false) for don't screw like me because of "Why I get same query values for every record?" question... :)

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.

10 Ekim 2013 Perşembe

AXAPTA - Join table A with table B and table A with table C

I can do this with a way which I got from a forum forumda . Trick is fetchMode command. Without fetchMode command can't generate a correct select command. 
Query query = new Query();
QueryBuildDataSource qbds,qbds1,qbds2;
;
qbds = query.addDataSource(tableNum(SMAServiceOrderTable));
qbds1 = qbds.addDataSource(tableNum(B_RepairJournal));
qbds1.fetchMode(QueryFetchMode::One2One);
qbds1.addLink(fieldNum(B_RepairJournal,ServiceOrderId),fieldNum(SMSServiceOrderTable,ServiceOrderId));
qbds2 = qbds.addDataSource(tableNum(InventTable));
qbds2.fetchMode(QueryFetchMode::One2One);
qbds2.addLink(fieldNum(SMAServiceOrderTable,ItemId),fieldNum(InventTable,ItemId));

info(qbds.toString());

5 Aralık 2011 Pazartesi

AXAPTA user tables

There are three tables about user relations:

UserInfo - There are active directory users at this table. User id at Id field and name at name field...

EmplTable - This is firms employee table. Employee code at  EmplId field.

SysCompanyUserInfo - This table ties UserInfo and EmplTable tables. UserId field at this table related with Id from UserInfo table, EmplId field at this table related with EmplId at EmplTable. You can call Administrator->User relations form for this relation.

CurUserId() gives you current users ID.
At this sample you created a table and you want to put default users employee id at create  new record:    MyTable.EmplId = SysCompanyUserInfo::find(CurUserId()).EmplId;