Showing posts with label 2012. Show all posts
Showing posts with label 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

How to get month Number in x++

How to get month of year in x++

 
static void mthYear(Args _arg)
{
    int s;
    ;
     s = mthOfYr(today());  
    print "Month of year is " + s;
 
    pause;
}

Tuesday, June 27, 2017

Run code based on configuration key in dynamics AX 2012

Sometimes you need to run code based on your configuration keys 

Code:


  if  (isConfigurationKeyEnabled (configurationkeynum(keyname)))
   {
                     // Code goes here..
   }
   else
   {
                // do something else
    }



Happing daxing

Create Sales Order in x++

Hi,
Today i am going to show you code how to create sales order in x++.
static void CreateSalesOrder(Args _args)
{
//declaring variables
SalesTable salesTable;
SalesLine salesLine;
NumberSeq numberSeq;
ttsBegin;
//creating sales order header
//getting sales order id from number sequence
numberSeq = NumberSeq::newGetNum(SalesParameters::numRefSalesId());
numberSeq.used();
salesTable.SalesId = numberSeq.num();
salesTable.initValue();
salesTable.CustAccount = ‘Demo-001′;
salesTable.initFromCustTable();
//validate
if (!salesTable.validateWrite()) {
throw Exception::Error;
}
salesTable.insert();
//creating sales order line
salesLine.SalesId = salesTable.SalesId;
salesLine.ItemId = ‘DM0012′;
salesLine.SalesQty = 2;
salesLine.LinePercent = 1;
salesLine.createLine(true, // Validate
true, // initFromSalesTable
true, // initFromInventTable
true, // calcInventQty
true, // searchMarkup
true  // searchPrice
);
ttsCommit;

//displaying sales order id
info(salesTable.SalesId);
}
And THEN run this job

Wednesday, April 12, 2017

Get current worker

Get current login worker:

HcmWorkerRecId workerRecId;
workerRecId = DirPersonUser::currentWorker();

Please note that it will return recid