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;   ...

Create purchase requisition using x++


Create purchase requisition using x++

A purchase requisition is an internal document that authorizes the Purchasing department to buy items.

If you want to create purchase requisition using x++ in D365FO you have to follow the steps below:

·         Create a runnable job  named as CreatePR

·         Copy and paste the below code in your job

class CreatePR
{
    public static void main(Args _args)
    {
        PurchReqTable   purchReqTable;
        PurchReqLine    purchReqLine;
        
        ttsbegin;
        //Purchase requisition header         
        purchReqTable.clear();
        purchReqTable.initValue();
        purchReqTable.PurchReqId    =  NumberSeq::newGetNum(PurchReqTable::numRefPurchReqId()).num();
        purchReqTable.PurchReqName  = 'PR from X++ Job';
        purchReqTable.insert();
         
        //Purchase requisition lines
        purchReqLine.clear();
        purchReqLine.initValue();           
        purchReqLine.initFromPurchReqTable(purchReqTable);
        purchReqLine.ItemId              = "Itemid";
        purchReqLine.BuyingLegalEntity   = CompanyInfo::find().RecId;
        purchReqLine.InventDimIdDataArea = curext();
        purchReqLine.PurchQty            = 2;
        purchReqLine.modifiedField(fieldNum(purchReqLine,ItemId));
        purchReqLine.insert();
        ttscommit;

        info(strFmt("Purchase requisition '%1' created successfully",purchReqTable.PurchReqId));
    }

}

·         Execute the job it will generate the Purchase requisition.

·         Go to Procurement & Sourcing -> All Purchase requisitions -> All purchase requisition


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