May 05, 2015

Error while Unit Testing [AX 2012 R3]

Hi All,
I was facing below error while running test cases for a customization. 


  • An internal error occurred in the remove operation in the SysTestRecordCleanUp#Context object cache.
  • A critical error has occurred in function SysTestRecordCleanUp::cleanUpContext.
  • An error has occurred. Contact your administrator for further assistance.

  • clip_image001 
    Solution: However i am not very much sure why this error was coming and what is the main reason for this, but I used below steps and its resolved this issue.
    1. Stop to AOS
    2. Delete AUC files from below path.
    3. Restart AOS.
    Try now, it should work fine.
    image
    -Harry

    April 26, 2015

    How to delete AUC files

    During many development we face some cache related issues. There is no error in code and still changes are not reflecting. Even after performing CIL, Compile and Sych but issue still existing. All these are happened due to ax_{GUID}.auc files. We need to clear(delete) these files from Appdata folder.
    To delete AUC(Application Unicode Cache) files we need to perform below steps.
    1. Stop AOS
    2. Delete AUC files from below path
    C:\Users\<UserId>\AppData\Local
    image
    3. Restart AOS.
    PS: AOS restart is not mandatory. Its better to do it in this way however it will work without AOS restart.
    More details on AUC
    -Harry

    April 20, 2015

    How to send Email through X++ code

    Hi All,

    Use below code to sent emails from X++ code. Below code is written in a Job you can reuse the same in your logic. 

    static void dpk_TestEmail(Args _args)
    {
        // Set these variables.
        str                                   sender = “sender@dnaitservices.com”;
        str                                   recipient = 'rcpt@dnaitservices.com';
        str                                   cc = 'cc@dnaitservices.com';
        str                                   subject = 'TheAxapta_Subject';
        str                                   body = 'TheAxapta_Msg';
        str                                   fileName = @'D:\test.txt';
        List                                  toList;
        List                                  ccList;
        ListEnumerator                        le;
        Set                                   permissionSet;
        System.Exception                      e;
        str                                   mailServer;
        int                                   mailServerPort;
        System.Net.Mail.SmtpClient            mailClient;
        System.Net.Mail.MailMessage           mailMessage;
        System.Net.Mail.MailAddress           mailFrom;
        System.Net.Mail.MailAddress           mailTo;
        System.Net.Mail.MailAddressCollection mailToCollection;
        System.Net.Mail.MailAddressCollection mailCCCollection;
        System.Net.Mail.AttachmentCollection  mailAttachementCollection;
        System.Net.Mail.Attachment            mailAttachment;
        ;
        try
        {
            toList = strSplit(recipient, ';');
            ccList = strSplit(cc, ';');
            permissionSet = new Set(Types::Class);
            permissionSet.add(new InteropPermission(InteropKind::ClrInterop));
            permissionSet.add(new FileIOPermission(filename, 'rw'));
            CodeAccessPermission::assertMultiple(permissionSet);
            mailServer = SysEmaiLParameters::find(false).SMTPRelayServerName;
            mailServerPort = SysEmaiLParameters::find(false).SMTPPortNumber;
            mailClient = new System.Net.Mail.SmtpClient(mailServer, mailServerPort);
            le = toList.getEnumerator();
            le.moveNext();
            mailFrom = new System.Net.Mail.MailAddress(sender);
            mailTo  = new System.Net.Mail.MailAddress(strLTrim(strRTrim(le.current())));
            mailMessage = new System.Net.Mail.MailMessage(mailFrom, mailTo);
            mailToCollection = mailMessage.get_To();
            while (le.moveNext())
            {
                mailToCollection.Add(strLTrim(strRTrim(le.current())));
            }
            le = ccList.getEnumerator();
            mailCCCollection = mailMessage.get_CC();
            while (le.moveNext())
            {
                mailCCCollection.Add(strLTrim(strRTrim(le.current())));
            }
            mailMessage.set_Priority(System.Net.Mail.MailPriority::High);
            mailMessage.set_Subject(subject);
            mailMessage.set_Body(body);
            mailAttachementCollection = mailMessage.get_Attachments();
            mailAttachment = new System.Net.Mail.Attachment(fileName);
            mailAttachementCollection.Add(mailAttachment);
            mailClient.Send(mailMessage);
            mailMessage.Dispose();
            CodeAccessPermission::revertAssert();
            info("Email sent.");
        }
        catch (Exception::CLRError)
        {
            e = ClrInterop::getLastException();
            while (e)
            {
                info(e.get_Message());
                e = e.get_InnerException();
            }
            CodeAccessPermission::revertAssert();
        }
    }

    -Harry

    April 13, 2015

    System trade line number increment is not specified.

    Hi Friends,

    I faced one Error while creating Purchase Order from Approved Purchase Requisition
    Error Message:
    System trade line number increment is not specified.
    Purchase order creation has been cancelled due to errors

    clip_image001

    Reason: As mentioned in error message there is one parameter missing.'

    Possible Solution:Click on “System Parameter” from infolog window or go to
    System administration -> Setup -> System Parameter
    Under System Line Number, Change the increment from 0 to 1.

    clip_image002

    Now try again to create PO.

    clip_image003

    Double click on purchase order number to open PO from.

    - Harry