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

Assign default values to form in D365FO


Assign default values to form in D365FO


·         Expand your desired data source node -> Events -> Select OnInitValue event -> Right click and copy event handler method

·         Create a new class

·         Paste the event handler method

·         Add code in it like below:

[FormDataSourceEventHandler(formDataSourceStr(HcmEmploymentLeave, HcmEmploymentLeave), FormDataSourceEventType::InitValue)]

public static void HcmEmploymentLeave_OnInitValue(FormDataSource sender, FormDataSourceEventArgs e)
{
     FormRun formRun = sender.formRun();
     Object hcmEmploymentLeave_ds = formRun.dataSource(formDataSourceStr(HcmEmploymentLeave, HcmEmploymentLeave)) as FormDataSource;
     HcmEmploymentLeave hcmEmploymentLeave = hcmEmploymentLeave_ds.cursor();
    
     //Assigning value to the field
     hcmEmploymentLeave.FIELDNAME= VALUE;
}

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