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;       Dialog dialog=new Dialog("Excel Import using dialog");       dialogUploadGroup=dialog.addGroup("@SYS54759");       formBuildControl=dialog.formBuildDesign().control(dialogUploadGroup.name());    

Create lookup in D365FO using X++


Create lookup in D365FO using X++


·         Open the form
·         Go to the form string control on which you want to show lookup
·         Go to the events of the form string control on forms
·         Right click the OnLookup event and click Copy event handler method
·         Create a new class and paste the event handler method in the class you have copied in the previous step
[FormControlEventHandler(formControlStr(Form, AccountNum), FormControlEventType::Lookup)]
public static void AccountNum_OnLookup(FormControl sender, FormControlEventArgs e)
{         
     //Add the lookup logic here.
}

·         Add the logic of the lookup in the event handler method like below:
[FormControlEventHandler(formControlStr(Form, AccountNum), FormControlEventType::Lookup)]
public static void AccountNum_OnLookup(FormControl sender, FormControlEventArgs e)
{  

        Query query = new Query();
        QueryBuildDataSource queryBuildDataSource;
        QueryBuildRange queryBuildRange;
   
        SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(custTable), sender);
   
        sysTableLookup.addLookupField(fieldNum(CustTable, AccountNum));
        sysTableLookup.addLookupField(fieldNum(CustTable, CustGroup));
   
        queryBuildDataSource = query.addDataSource(tableNum(CustTable));
   
        queryBuildRange = queryBuildDataSource.addRange(fieldNum(CustTable, CustGroup));
        queryBuildRange.value('40');
   
        sysTableLookup.parmQuery(query);
   
        sysTableLookup.performFormLookup();
   
     

    
}

Comments

Popular posts from this blog

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

Customize SSRS report using extension in D365FO

CREATE AND POSTING PURCHASE ORDER THROUGH X++ DYNAMICS AX