2016-03-21

[AX2012] Ax error "A user session on the server could not be created. Try to start the client again. If the problem continues contact Ax Administrator"

I checked the Event viewer and found that the log file was full:
Object Server 01:  The database reported (session 1 (-AOS-)): [Microsoft][SQL Server Native Client 10.0][SQL Server]The transaction log for database
'AXDatabase' is full due to 'LOG_BACKUP'. . The SQL statement was: "UPDATE SQLSYSTEMVARIABLES SET VALUE='34' WHERE PARM='SYSVARID'"

Solution:
Stop the AOS.
Shrink database log file and start the AOS.

2016-03-20

[AX2012] Enable/Disable Buttons on PurchTable or SalesTable Form by Code

To enable or disable buttons on PurchTableListPage, PurchTable, SalesTableListPage or SalesTable form, you can edit on these classes:
  • PurchTableListPageInteraction
  • PurchTableInteraction
  • PurchTableInteractionHelper
  • SalesTableListPageInteraction
  • SalesTableInteraction
  • SalesTableInteractionHelper
You can add some additional code to enable or disable buttons, for example buttonConfirm in PurchaseTable form. Find this button name in PurchTableInteraction class and add your code.
These class can affect PurchTableListPage or SalesTableListPage forms.

2016-03-17

[AX2012] QR Code

Here is the sample to generate QR Code in AX 2012. This code can be used for report by save the binData.getData() into container field in report temporary table. You can download the xpo here.

public class FormRun extends ObjectRun
{
    Microsoft.Dynamics.QRCode.Encoder   qrCode;
    System.Drawing.Bitmap               netBitmap;
    BinData                             binData;
    Image                               image;
}


public void init()
{
    super();
    qrCode = new Microsoft.Dynamics.QRCode.Encoder();
   
qrCode.set_Version(40);
 qrCode.set_ErrorCorrectionLevel(Microsoft.Dynamics.QRCode.ErrorCorrectionLevel::High);
    binData = new BinData();
    image   = new Image();
}


void createQR()
{
    Filename            filename;
    FileIOPermission    perm = null;
    ;

    netBitmap   = qrCode.Encode(Text.text());
    filename    = qrCode.GetTempFile(Text.text());
    perm        = new FileIOPermission(filename, 'RW');
    perm.assert();

    binData.loadFile(filename);
    image.setData(binData.getData());//binData.getData() return a container
    QRImage.image(image);
    if(WinAPI::fileExists(filename))
    {
        WinAPI::deleteFile(filename);
    }
    CodeAccessPermission::revertAssert();

    //info(filename);
}


public void textChange()
{
    super();
    element.createQR();
}

2016-03-16

[AX2012] SSRS Report Error at The Fisrt Time After Restarting AOS



"The DefaultValue expression for the report parameter ‘AX_CompanyName’ contains an error: Request for the permission of type ‘System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ failed. (rsRuntimeErrorInExpression)"

Solution:
  1. Go to System administration>Setup>System>System service accounts.
  2. Retype the business connector proxy account ("domain\username").

2012-12-14

[AX2012] "Microsoft Dynamics AX 2012 for Developer" in Compiled HTMLFormat (.chm)

"Not work on Windows 10"
Dokumen Help "Microsoft Dynamics AX 2012 for Developer" dalam bentuk file .chm bisa di unduh di tautan berikut:

"Microsoft Dynamics AX 2012 for Developer" help file in compiled format (.chm) can be downloaded below:

Google:
Microsoft Dynamics AX 2012 for Developer.chm
Dropbox:
Microsoft Dynamics AX 2012 for Developer.chm

2012-03-31

[AX2009] Export Import User Group Security

Export security setting dari current AOS:
  1. Administration»Periodic
  2. Data export/import
  3. Fokus ke Definition groups
  4. Input Definition group.
  5. Input Definition group name.
  6. Pilih Standard sebagai Type nya.
  7. Klick Options tab
  8. Cek "Include system tables" checkbox (system tables).
  9. Klik tombol Table setup.
  10. Masukkan daftar tabel:
    1. AccessRightsList* - menyimpan security permissions untuk User groups
    2. UserGroupInfo* - menyimpan User groups
    3. DomainInfo* - menyimpan Domains
    4. UserGroupList - menyimpan anggota User group
    5. UserInfo - menyimpan User AX
    6. SysUserInfo - menyimpan User AX setting.
    7. CompanyDomainList - menyimpan keterhubungan company/domain
  11. Klik tombol Export to.
  12. Pilih lokasi, nama, dan simpan filenya (.dat).
  13. OK
Import ke target AOS:
  1. Administration»Periodic
  2. Buka Data export/import
  3. Pilih Import
  4. Pilih Definition group atau kosongkan saja.
  5. Pilih file .dat yang sudah diexport td.
  6. Ok
Sumber: MSDN

2012-03-16

Function monthDiff

Mencari rentang/jumlah bulan dari suatu periode. Masih mencari function terbaik.
int monthDiff(TransDate _fromDate, TransDate _toDate)
{
    TransDate   fromDate = _fromDate, toDate = _toDate;
    int         yrDiff;
    int         totalMonth;
    int         fdtDay = dayofmth(fromDate);
    //int         tdtDay = dayofmth(toDate);
    int         frMth = mthofyr(fromDate);
    int         toMth = mthofyr(toDate);
    int         countMth;
    int         fYear = year(fromDate), tYear = year(toDate);
    date        procDt;
    ;
    yrDiff = yearDiff(toDate, fromDate);

    countMth = frMth;
    totalMonth = 0;

    if(!yrDiff)
    {
        while(fYear<=tYear)
        {
            while(countMth<=12)
            {
                if((fYear == tYear) && (countMth == toMth))
                    break;

                countMth++;
                totalMonth++;
            }
            fYear++;
            countMth = 1;
        }
    }
    else
    {
        tYear = tYear - yrDiff;

        while(fYear<=tYear)
        {
            while(countMth<=12)
            {
                if((fYear == tYear) && (countMth == toMth))
                    break;

                countMth++;
                totalMonth++;
            }
            fYear++;
            countMth = 1;
        }
        totalMonth += (12 * yrDiff);
    }
    procDt =  mkdate(fdtDay,toMth,fYear-1);
    if(!(dayofmth(procDt)<fdtDay))
        procDt--;

    if(toDate<(procDt))
        totalMonth--;
    
    fYear = year(fromDate);
    if(fYear == tYear && frMth == toMth && fromDate == dateStartMth(fromDate) && toDate == dateEndMth(toDate))
        totalMonth++;

     return totalMonth;
}