Showing posts with label AX 2012. Show all posts
Showing posts with label AX 2012. Show all posts

Wednesday, April 4, 2018

Get next Month in x++

 

How to get next month date in x++

 static void mthName(Args _arg)
{
      Transdate s; ;

      s = nextMth(today());
   print "next month date is " + s;
 
   pause;
} 
 
Happy Daxing! 
 

Monday, April 2, 2018

Get month name in X++

How to get name of month in x++

 
static void mthName(Args _arg)
{
    str s;
    ;
 
    s = mthName(8);  
    info(strfmt("Month name is %1" , s));
 
}
 
Happy Daxing! 

Tuesday, June 27, 2017

Difference among Research() and Research(true) in AX 2012

Difference among Research() and Research(true) in AX 2012

Research
Calling research() will return the existing form query against the database, therefore updating the list with new/removed records as well as updating all existing rows. This will honor any existing filters and sorting on the form, that were set by the user.
Research(true)
The research method starting with AX 2009 accepts an optional boolean argument_retainPosition. If you call research(true), the cursor position in the grid will be preserved after the data has been refreshed. This is an extremely useful addition, which solves most of the problems with cursor positioning (findRecord method is the alternative, but this method is very slow).

Post/Create Sales order Packing slip x++

Hi Folks,

Today i am going to show you code how to create and post Packing slip through x++;

static void createPostSalesPackingSlip(Args _args)
{
    SalesTable salesTable;
    SalesFormLetter salesFormLetter;

    salesTable = SalesTable::find('SO-ASC001');
      //Posting Sales Order 
    salesFormLetter=SalesFormLetter::construct(DocumentStatus::PackingSlip);
    salesFormLetter.update(SalesTable::find(sid));
       salesFormLetter.update(salesTable,systemDateGet(),SalesUpdate::All,AccountOrder::Non e, NoYes::No,NoYes::Yes);
    info("Sales Order Status is Delivered");
}

run this job.

AX2012 R3: E-Learning Links

Microsoft Learning Official Courseware:
Warehouse Management Official Course: https://dynamics.microsoftelearning.com/eLearning/courseDetail.aspx?courseId=450776
Transportation Management Official Course: https://dynamics.microsoftelearning.com/eLearning/courseDetail.aspx?courseId=450777
Tech Conference and other material on InformationSource:

Easy way to get SID for Microsoft Dynamics Ax

Most of the time when we restore other developer database ,or Client database 

Unable to log on to Microsoft Dynamics AX” error message when opening the AX client”

   we want to get the SID for the current user setting, here are the steps you  can perform to successfully log on to Dynamics AX:
1. Open the command prompt and type "wmic path win32_useraccount where name="{Domain user name}" get sid"  Press Enter
                                               OR
    Run CMD as administrator and write command "WHOAMI /USER" it will return SID

2. Copy the SID.
3. Open the SQL server and write following command to update current admin user:

             use {AX DB}
             update USERINFO
             set SID = '{paste the SID here from step#2}', NETWORKDOMAIN='{Network domain}',         NETWORKALIAS='{User Id}' where ID='Admin'

OR 

3. You can find UserInfo table under Microsft Dynamics AX 2012 Database.
     (a). Right Click on table node --> select Edit rows -- > Update SID where ID = Admin
     (b) Replace  Network Alias   with your user domain name example "Daniyal.aslam" in               my case.
     (c) Replace NetworkDomain  with your domain name example "abc@contoso.com" in               case when we copy database from Client or Live environment where domain name is             different from Production environment

Create Inventory Movement Journal through x++

           Create Inventory Movement Journal Through x++

static void CreateInventJournal(Args _args)
{
       InventJournalTable inventJournalTable;
       InventJournalTrans inventJournalTrans;
       InventJournalName inventJournalName;
       InventDim inventDim;
       JournalCheckPost journalCheckPost;

//Below code creates journal header
       inventJournalTable.clear();
       inventJournalName = InventJournalName::standardJournalName(InventJournalType::Movement);
       inventJournalTable.initFromInventJournalName(InventJournalName::find(inventJournalName ));
       inventJournalTable.insert();

//Below code creates journal lines
       inventJournalTrans.clear();
       inventJournalTrans.initFromInventJournalTable(inventJournalTable);
       inventJournalTrans.TransDate = systemDateGet();
       inventJournalTrans.ItemId = "000004";
       inventJournalTrans.Qty = 100;
       inventDim.InventSiteId = '12';
       inventDim.InventLocationId = '1201';
       inventDim.wMSLocationId = 'BULK-001';
       inventJournalTrans.InventDimId = inventDim::findOrCreate(inventDim).inventDimId;
       inventJournalTrans.insert();

//The below code posts the journal
      journalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalTable);
      journalCheckPost.run();
}

Update label description using X++

I have requirement where i need to update label for ssrs report parameter

Here is my solution for updating label

static void updateLabelJob(Args _args)
{
    SysLabelEdit     sysLabelEditLocal;
 
    sysLabelEditLocal = new sysLabelEdit();

    info(strFmt('Before Label changes : %1', "@DAN1"));
 
    sysLabelEditLocal.labelModify('en-us',  sysLabelEditLocal.findLabel('en-us', 'Demo Parameter'),                                                          "SSRSTEST", "", SysLabelApplModule::None);
 
    info(strFmt('After Label changes : %1', "@IQL112"));
}

Synchronization through x++ code / Unable to do DB Sync through AOT

Synchronization forcefully DB through X++ 


here is the code for synchronization DB in X++.

static void DBSync(Args _args )
{
    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("TEst");
    errorStack = new StackBase(Types::String);
    lastIdx = 0;
    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 in table '%1 (%2)'",tableId,dict.tableName(tableId));
        errorStack.push(errorTxt);
        retry;
    }

    setPrefix('Test2');
    errorTxt = errorStack.pop();

    while (errorTxt)
    {
        error(errorTxt);
        errorTxt = errorStack.pop();
    }
}

now run job.