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.

     select companyinfohsd where companyinfohsd.dataAreaId=="dat";  
     select companyinforss where companyinforss.dataAreaId=="ceu";  
     select forupdate hcmEmployment where hcmEmployment.Worker==hcmWorker.RecId && hcmEmployment.LegalEntity==companyinfohsd.RecId;  

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");  

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  

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;  
       select Salestablelocal  
         where Salestablelocal.Salesid ==this.parmSalesid()  
           && Salestablelocal.salestype==SalesType::ItemReq  
           && Salestablelocal.SalesStatus==SalesStatus::Backorder;  
           salesFormLetter = SalesFormLetter::construct(DocumentStatus::Confirmation);  
           salesFormLetter = SalesFormLetter::construct(DocumentStatus::ProjectPackingSlip);  
           msg = "Item Requirement with Sales order id : " + this.parmSalesid() + " Posted ";  
           msg = "Item Requirement with Sales order id: "+ this.parmSalesid() + " already posted";  
      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 )  

Get particular Financial dimension value from default dimension in Axapta

To get particular dimension value from default dimension you can try below code as per your requirement.

  DimensionAttributeValueSetItem dimvalue;  
   DimensionAttributeValue dimAttValue;  
   DimensionAttribute dimAtt;  
   int length;  
   //DimAttributeOMCostCenter  viewCostCenter;  
   DimensionFinancialTag    viewCostCenter;  
   DimAttributeOMDepartment  viewDepartment;  
   DimensionFinancialTag    locations;  
   str name;  
   length = 0;  
   Select dimvalue  
   join dimAttValue  
   join dimAtt  
   Where dimvalue.DimensionAttributeValueSet == _DimensionDefault  
   && dimvalue.DimensionAttributeValue == dimAttValue.RecId  
   && dimAttValue.DimensionAttribute == dimAtt.RecId  
   && dimAtt.Name == 'ProductCategory';  
   select viewCostCenter  
   where viewCostCenter.Value == dimValue.DisplayValue;  
   return viewCostCenter.Description;  

Import Budget Register line In Ax 2012

To Import Budget Register line In Ax 2012, you get Idea from below code. You need to create budget register header then you can your CSV file and apply the code to import. you also need to declare variables as used in below code.

            budgetTransactionLine = new AxBudgetTransactionLine();  
         accEntryPattern = [strFmt("%1-%2-%3-%4-%5-%6-%7",c3,c4,c5,c6,c7,c8),c3];  
               accEntryPattern += "LegalEntity";  
               accEntryPattern += c4;  
               accEntryPattern += "Region";  
               accEntryPattern += c5;  
               accEntryPattern += "BusinessUnit";  
               accEntryPattern += c6;  
               accEntryPattern += "Activity";  
               accEntryPattern += c7;  
               accEntryPattern += "Department";  
               accEntryPattern += c8;  
         accEntryPattern = conIns(accEntryPattern,3,dimcount);  
         budgetTransactionLine.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(accEntryPattern));  ;  

Class and method to post packing slip for all load form in ax 2012

In warehouse management In Ax 2012, All loads form exists and load can be created from purchase orders and you can post packing slip from load form.

If you have any customization during packing slip posting then you can refer below class method to put your code.


If you want to update anything in vendPackingSlipJour and vendPackingSlipTrans table during packing slip posting. Then you can refer below class.


Happy daxing.

Microsoft Windows : Understanding Control panel features and system settings

I want to share one interesting clip from Youtube which will show you Control panel features and settings for  Windows operating system.

If you like this clip then waiting for your subscription to get daily updates on new topics.