How to Import Records from Excel Using X++ Code in D365FO

  How to Import Records from Excel Using X++ Code in D365FO   Include the below namespace in X++ code it will requires to import Excel. Using System.IO; Using OfficeOpenXml; Using OfficeOpenXml.ExcelPackage; Using OfficeOpenXml.ExcelRange;   In addition to the basic reference, include (Directory and DirectoryUpgrade Packages) X++ Code: Using System.IO; Using OfficeOpenXml; Using OfficeOpenXml.ExcelPackage; Using OfficeOpenXml.ExcelRange; class ReadExcel {   public static void main(Args _args)    {     Int id;     Str Name;      System.IO.Stream stream;       ExcelSpreadsheetName sheet;              FileUploadBuild fileUpload,fileUploadBuild;       DialogGroup dialogUploadGroup;       FormBuildControl formBuildControl;   ...

Pass field value from SalesTable to CustTrans in AX 2012 & D365FO

Pass field value from SalesTable to CustTrans in AX 2012 & D365FO


AX 2012 

 

Following are the steps to pass the value from Sales Table to custtrans.

 

1) Create a new field

 

2) Create the parm method for that field on CustVoucher class

 

3) Assign field value to this parm method in SalesInvoiceJournalPost.postCustVend() method by using the salesTable buffer

 

4) Add the code for assigning the variable value(or the parm method value) in CustVoucher.initCustVendTrans() method

 

And now post an invoice and go to custTrans table to check the field value.

 

 

D365FO

 

Add the field in SalesTable 

Add the field in CustTrans

Create Extension class of SalesInvoiceJournalPost

Override postCustVend method using coc 

 

[ExtensionOf(classStr(SalesInvoiceJournalPost))]

final class SalesInvoiceJournalPost_Extension

{

    /// <summary>

    ///   customer related postings.

    /// </summary>

    protected void postCustVend()

    {

        CustTrans                   custTrans;

        

        next postCustVend();

 

        // getting the customer transaction

        custTrans                   = CustTrans::findByVoucher(this.custInvoiceJour.LedgerVoucher);

        custTrans.selectForUpdate(true);

 

        // updating the transaction

        ttsbegin;

        custTrans. Name = this.SalesTable.Name;

        custTrans.update();

        ttscommit;

    }

}



Comments

Popular posts from this blog

D365 FO: REFRESH CALLER FORM DATA SOURCE FROM A CLASS X++

Passing Args from one Form to another Form in dynamics AX

CREATE AND POSTING PURCHASE ORDER THROUGH X++ DYNAMICS AX