Thursday, May 14, 2015

How to delete Label Files from AX 2012

Here are the steps to delete Label Files from AX 2012:

  • Create a new model. You could call it "Test".
  • Open the AOT and move the Label File(s) you want to get rid of to the new model.
  • Close AX and stop the AOS.
  • Use AXUtil to delete the new model.
  • Select the label files (name start with 'ax' and followed with label id. select all files) and Delete from the server folder; C:\Program Files\Microsoft Dynamics AX\60\Server\...\bin\Application\Appl\Standard
  • Start the AOS.
  • Skip the upgrade wizard.

Friday, February 6, 2015

Read text file and SubStr to fetch fixed length columns - AX 2012

static void readTextFile(Args _args)
{
    Container               con;
    Filename                filename, Filename2;
    FileIOPermission        permission;
    TextIO                  textIO, textIO1;
    Str1260                 line;
    #File
    ;
    
    Filename = @"C:\Test\testFile.txt";
    permission = new fileIOpermission(filename,"RW");
    permission.assert();
    textIO = new TextIO(filename,#io_read);
    //textIO.inFieldDelimiter('|');
    if(textIO)
    {
        while(textIO.status() == IO_Status::Ok)
        {
            con = textIO.read();
            if(con)
            {
                line = Global::con2Str(con);
                info(strFmt("text - %1",line));
                info(strFmt("Company id - %1",subStr(line,1,4)));
                info(strFmt("code - %1",subStr(line,5,6)));
                info(strFmt("account num - %1",subStr(line,12,14)));
                info(strFmt("transdate - %1",subStr(line,26,6)));
                info(strFmt("Cheque num - %1",subStr(line,32,10)));
                info(strFmt("amount - %1",subStr(line,42,8)));
                break;
            }
        }
    }
}

Customer payment journal through X++ Code - AX 2012

static void cust_GLPosting(Args _args)
{
    Ledgerjournalname       ledgerjournalname;
    LedgerjournalTable      LedgerjournalTable;
    LedgerjournalTrans      LedgerjournalTrans;
    LedgerjournalCheckPost  LedgerjournalCheckPost;
    NumberSeq               numberSeq;
    Container               con;
    Filename                filename, Filename2;
    FileIOPermission        permission;
    TextIO                  textIO, textIO1;
    Dialog                  dialog;
    DialogField             dialogField;
    AccountNum              customerAccount= 'BRMF-000001';
    AccountNum              offsetAccNum = 'B01';
    #File

    select ledgerjournalname where ledgerjournalname.JournalName == "Test";
    ttsBegin;
    LedgerjournalTable.JournalName = ledgerjournalname.JournalName;
    LedgerjournalTable.initFromLedgerJournalName();
    LedgerjournalTable.JournalNum  = JournalTableData::newTable(LedgerjournalTable).nextJournalId();
    LedgerjournalTable.insert();
    ttsCommit;
        
    ttsBegin;
    numberSeq                               =   NumberSeq::newGetVoucherFromId((ledgerjournalname.NumberSequenceTable));
    LedgerjournalTrans.Voucher              =   numberSeq.voucher();
    LedgerjournalTrans.JournalNum           =   LedgerjournalTable.JournalNum;
    LedgerjournalTrans.CurrencyCode         =   "USD";
    LedgerjournalTrans.ExchRate             =   Currency::exchRate(LedgerjournalTrans.CurrencyCode);
    LedgerjournalTrans.AccountType          =   LedgerJournalACType::Cust;
    LedgerjournalTrans.parmAccount(customerAccount,LedgerjournalTrans.AccountType);
    LedgerjournalTrans.Txt                  =   'Testing';//conPeek(con,1);
    LedgerjournalTrans.AmountCurCredit      =   200;//conPeek(con,3);
    LedgerjournalTrans.TransDate            =   systemDateGet();//str2Date(conPeek(con,4),123);
    LedgerjournalTrans.OffsetAccountType    =   LedgerJournalACType::Bank;//LedgerjournalTable.OffsetAccountType;
    //LedgerJournalTrans.offsetacco
    LedgerjournalTrans.OffsetLedgerDimension =   22565431567; //LedgerjournalTable.OffsetLedgerDimension;
    LedgerjournalTrans.DefaultDimension     =   CustTable::find(customerAccount).DefaultDimension;
    LedgerjournalTrans.OffsetDefaultDimension=  CustTable::find(customerAccount).DefaultDimension;
    LedgerjournalTrans.insert();
    ttsCommit;
               
    LedgerjournalCheckPost = LedgerjournalCheckPost::newLedgerJournalTable(LedgerjournalTable,NoYes::Yes);
    LedgerjournalCheckPost.run();
    
}

Tuesday, January 20, 2015

10 Steps - After changing domain of AX VM you need to follow

Hi Friends,

Here are the 10 easy steps to follow after changing the domain name of the microsoft dynamics AX VM

  1. Create user (AXAdmin) (or you can use any dedicated user from the domain) and add this user administrator group.
  2. Go to registry and path - HKLM\Software\Microsoft\WindowsNT\CurrentVersion\ProfileList. In this path you will find the SID for newly created user. Copy this SID for step 3



  1. Copy SID and goto path HKLM\Software\Microsoft\Dynamics\6.0\Setup\DynamicsServer. Here change the Account key value with new user id and SetupUser with the SID which we copied previously.





  1. Login into the Sql server management studio and add newly created user id for all required databases.
  2. In MicrosoftDynamicsAX database open UserInfo table in editing mode and for 'Admin' user update SID, NetworkDomain and NetworkAlis
  3. Open SYSBCPROXYUSERACCOUNT table in editing mode and update SID, NetworkDomain and NetworkAlis
  4. Open Reporting services configuration Manager and change the Service account and Execution account and check report manager url (browse this url and check whether it's showing DynamicsAX folder and reports). Sometimes report server url is throwing encryption key error. Go to reporting services configuration and in Encryption Keys select the option of Deleted encrypted content and select Delete button. Just verify again by browsing report url.
  5. Go to services and locate microsoft dynamics AX service - change the log on property with the new userid
  6. Check the AX Server and client configuration for database connection details if your database server name is changed.
  7. Start the Microsoft Dynamics AX service and Logon to AX.

Tuesday, December 23, 2014

How to import Contoso Demo Data to Dynamics AX 2012 R3

The setup contoso demo data for Dynamics Ax 2012 R3 is different from previous version. I remember, I used .dat file to load demo data into Dynamics Ax 2012 R2. Now DynamicsAX2012R3DemoData.exe available partner Resource.
03-Demo setup
DynamicsAX2012R3DemoData.exe extracted files round 15 GB. Extracted folder contains three types of files. According to MSDN
  • Xml (A bcp data file that contains table data. Columns are separated by #|EOC|#. Rows are separated by #|EOR|#\n.)
  • Out (A bcp data file that contains the table metadata (column descriptions).
  • OutModel (This metadata includes all names and IDs of the table and its fields. This file also includes the elementType attribute, which stores the names and IDs of any Microsoft Dynamics AX tables, classes, or extended data types that are referenced by the table)
Installation of Test Data Transfer Tool:
The MSDN Described The Import export with Test Data Transfer Tool (beta) as follow.
IC665318


Test Data transfer Tool is available on partner resource.
Go on following link

04-InformationSource

On login I found download page
05-download

There will be zip file downloaded.  On running I found following installation wizard.

11-Beta Setup

12-Beta Setup next

Setup run will be generated as following
06-folderDetail

Import Data Into Dynamics Ax 2012 R3 instance:
And import MetaDataXMLGenerator.xpo in dynamics Ax.
07-ImportGenerator

This xpo imports results a job inside job node under AOT.

08-Job



This job will generate Metadata.xml. This Metadata.xml will be created in window temporary folder.
Path of file in metadata.xml can be get from infobox which will appear after successful run of job.
13-metaFile

if you lost infobox,You can get temporary folder path with following command echo %temp%. where you can get Metadata.xml
Copied metadata.xml into [list] folder of test tool Data folder. If it already exists then overwrite it.
15-copy meta data

Now open command prompt. Go to directory where Test import tool is extracted.
Run the following command
DP.exe IMPORT “E:\Contoso_Demo_Data\DynamicsAXR3DemoData” MicrosoftDynamicsAx

Please update path according to your installation.
09-Command Prompt

After running the command, you will find following window which describe the process by remaining table to number data, and number of error occurs during import.
10-Remaining

This process takes hours and hours with respect to your machine. After completion, I found demo data inside my dynamics Ax 2012 R3.

14-DataAppear

Thanks to Ali

Friday, December 19, 2014

List all the objects from the project node in AX 2012

Hi MSDAX technical consultants,

In Microsoft dynamics AX 2012 to find all the objects from the projects you can use following code. 

static void listAllObjectosFromProject(Args _args)
{
    #define.Shared("Shared")
    
    ProjName            projName = "Test";
    ProjectListNode     list = infolog.projectRootNode().AOTfindChild(#Shared);
    TreeNodeIterator    ir = list.AOTiterator();
    ProjectNode         pnProj;
    ProjectNode         pn = list.AOTfindChild(projName);

    void searchAllObj(projectNode rootNode)
    {
        #TreeNodeSysNodeType
        TreeNode          childNode;
        TreeNodeIterator  rootNodeIterator;
        ;

        if (rootNode)
        {
            rootNodeIterator = rootNode.AOTiterator();
            childNode = rootNodeIterator.next();
            while (childnode)
            {
                if (childNode.treeNodeType().id() == #NT_PROJECT_GROUP)
                {
                    searchAllObj(childNode);
                }
                else
                {
                    //info(strfmt("Group :%1 - Object: %2", rootNode.AOTname(), childNode.AOTname()));
                    info(strfmt("%1", childNode.AOTname()));
                }
                childNode = rootNodeIterator.next();
            }
        }
    }
    ;

    if (pn)
    {
        //info(strFmt("Project %1:", projName));
        pnProj = pn.loadForInspection();
        searchAllObj(pnProj);
        pnproj.treeNodeRelease();
    }
    else    
    {
        info("Projet objects");
    }

}