Microsoft Dynamics Ax 2012 ERP Clip collecton

You can visit following link to view one by one videos which is related to Microsoft Dynamics Ax  Technical and functional Tutorials.

Axapta Development Online clips

Ax Functional Material Collection

SSRS Reports And SQL

SQL and SSRS Reporting

You can subscribe above channel to get daily updates on new topics and get expertise in ERP .

Change tableid of of table by code in Axapta

If you want to change tableid of particular table then you can try below code. This is sample to Change tableid of of table by code in Axapta

 ReleaseUpdateDB::changeTableId(104924, 205001,'Table1');  

Code To generate BOM id for BOM Item in Axapta 2012

Following Code To auto generate BOM id for BOM Item in Axapta 2012.

   NumberSeq    numberSeq;  
     numberSeq = BOMTable::numberSeq();  
     numberSeq.used();  
     return numberSeq.num();  

How to change Company of Employee in Axapta by code

To change Company of Employee in Axapta by code you can get hint by below code. Its tedius task to update you need to do it very carefully and understand then code then apply in your customization.

 ttsBegin;  
     hcmWorker=hcmWorker::findByPersonnelNumber(Personalumberid);  
     select companyinfohsd where companyinfohsd.dataAreaId=="dat";  
     select companyinforss where companyinforss.dataAreaId=="ceu";  
     select forupdate hcmEmployment where hcmEmployment.Worker==hcmWorker.RecId && hcmEmployment.LegalEntity==companyinfohsd.RecId;  
     hcmEmployment.LegalEntity=companyinforss.RecId;  
     hcmEmployment.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);  
     hcmEmployment.doUpdate();  
     ttsCommit;  

Insert Records in Item batch Table by code in Ax 2012

To Insert Records in Item batch Table by code in Ax 2012 you can take hints from below code. First, you need to check whether a record exists or not in the inventbatch table if it does not exist then you can insert records.

  if (InventBatch::exist(Itemid,Inventbatchid))  
     {  
     //error("Batchnumber already exists");  
     }  
     else  
     {  
       inventBatch.itemId=Itemid;  
       inventBatch.inventBatchId=Inventbatchid;  
       inventBatch.prodDate=mkDate(1,12,2017);//systemDateGet();  
       inventBatch.insert();  
     }  

Product transaction cycle from Creation of item to sales , purchase and on hand in Ax 2012

By viewing below clip you will able to know Product transaction cycle from Creation of item to sales and purchase and on hand physical in Ax 2012.

1. How to create Item in ax 2012 and assign item group, tracking dimension etc
2.Create, confirm and post-purchase order in the system.
3.Create, validate and post-movement journal in the system.
4.Create, confirm and post-sales order in the system.
5. On hand effect checking on the item on each process against inventory dimension.

Please visit and see the clip and subscribe on youtube to get more updates.


How to convert Amount in Accounting currency in Ax 2012

To convert Amount in Accounting currency in Ax 2012 you can take help of below code, first you need to find accounting currency then you can pass the value of currency using method calculatecurrencytocurrency .
Here an example to convert delivery remainder to accounting currency.

  Ledger         ledger;  
   Currencycode      accCurrency;  
   CurrencyExchangeHelper currencyExchangeHelper;  
   AmountMst        amountMST;  
   select ledger  
     where ledger.PrimaryForLegalEntity == CompanyInfo::findByCompany_IN(curext()).RecId;  
   accCurrency       = ledger.AccountingCurrency;  
   currencyExchangeHelper = CurrencyExchangeHelper::newExchangeDate(Ledger::current(), systemDateGet());  
   amountMST        = currencyExchangeHelper.calculateCurrencyToCurrency(this.CurrencyCode , accCurrency ,1 , true);  
   return this.SalesPrice * this.RemainSalesPhysical * amountMST;  

How to get Accounting Currency value for Company in Ax 2012

To get Accounting Currency value for Company in Ax 2012, you can try below code in the display method of the table.

 public display CurrencyCode AccountingCurrency()  
 {  
   Ledger ledger;  
   select ledger  
     where ledger.RecId == CompanyInfo::find().RecId;  
   return ledger.AccountingCurrency;  
 }  

Auto Submit Workflow for Approval in Ax 2012

Sometimes we need to submit Auto Submit Workflow for Approval in Ax 2012 then you can try below code by job. One thing you need to remember submitter should not be approval in workflow designer if its then this job may create some issue on approval.

Rest is fine you can use this code for your customization.


 Inventtable inventtable =InventTable::find("628034tr1");  
 Workflow::activateFromWorkflowType("InventApprWFType", //Template name  
 inventtable.RecId, //Record id of the document that you are submitting,  
 'Auto-Submitted into workflow', //A comment for the workflow history to know something about how this was submitted,  
 false,//This document wasn't submitted from the web,  
 'userid1'); // T  
   info("done");  

X++ code for Project Item Requirement posting in Ax 2012

Below is the X++ code for Project Item Requirement posting in Ax 2012.

  SalesFormLetter salesFormLetter;  
   salesTable Salestablelocal;  
   str 200 msg;  
   if(this.parmSalesid())  
   {  
     changeCompany(_legalentity)  
     {  
       select Salestablelocal  
         where Salestablelocal.Salesid ==this.parmSalesid()  
           && Salestablelocal.salestype==SalesType::ItemReq  
           && Salestablelocal.SalesStatus==SalesStatus::Backorder;  
       if(Salestablelocal)  
       {  
         ttsBegin;  
           salesFormLetter = SalesFormLetter::construct(DocumentStatus::Confirmation);  
           salesFormLetter.update(Salestablelocal);  
           salesFormLetter = SalesFormLetter::construct(DocumentStatus::ProjectPackingSlip);  
           salesFormLetter.update(Salestablelocal);  
         ttsCommit;  
           msg = "Item Requirement with Sales order id : " + this.parmSalesid() + " Posted ";  
       }  
       else  
       {  
           msg = "Item Requirement with Sales order id: "+ this.parmSalesid() + " already posted";  
       }  
     }  
   }  
   else  
   {  
      msg = "Item Requirement with provided Sales order id does not exists";  
   }  

Seeking help to get Miscellaneous charges for Purchase order in Ax 2012

If you are Seeking help to get Miscellaneous charges for the Purchase order in Ax 2012 then this code can help you.

Sometimes we need to display Miscellaneous charges total in the report then you can get help as per below code.

  while select sum(Value),MarkupCode from markuptrans_txt group by MarkupCode join purchline where purchline.RecId ==markuptrans_txt.TransRecId  
                                     && markuptrans_txt.TransTableId == purchline.tableid  
                                     && purchline.PurchId == vendPurchOrderJour.PurchId  
                                     && markuptrans_txt.Value != 0.00  
   {  
     purchPurchaseOrderHeader.MiscChargeDesc = purchPurchaseOrderHeader.MiscChargeDesc+strFmt("Add %1 : \n",MarkupTable::find(MarkupModuleType::Vend,markuptrans_txt.MarkupCode).Txt )  
    ;