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