hi All,
I wrote below code to Import customer account form excel to d365fo
Using System.IO;
Using OfficeOpenXml;
Using OfficeOpenXml.ExcelPackage;
Using OfficeOpenXml.ExcelRange;
class ARP_ExcelImport
{
///
/// Runs the class with the specified arguments.
///
/// The specified arguments.
public static void main(Args _args)
{
// Part 1
System.IO.Stream stream;
CustTable custTable;
AccountNum accountNum;
ExcelSpreadsheetName sheet;
FileUploadBuild fileUpload,fileUploadBuild;
DialogGroup dialogUploadGroup;
FormBuildControl formBuildControl;
Dialog dialog = new Dialog("Excel Import");
dialogUploadGroup = dialog.addGroup("Select Excel File");
formBuildControl = dialog.formBuildDesign().control(dialogUploadGroup.name());
fileUploadBuild = formBuildControl.addControlEx(classStr(fileUpload),"UploadExcel");
fileUploadBuild.style(FileUploadStyle::MinimalWithFilename);
fileUploadBuild.fileTypesAccepted(".xlsx");
if(dialog.run() && dialog.closedOk())
{
FileUpload fileUploadControl=dialog.formRun().control(dialog.formRun().controlId("Upload"));
FileUploadTemporaryStorageResult fileUploadResult = file::GetFileFromUser(classStr(FileUploadTemporaryStorageStrategy));
// end of Part 1
// Part 2
if(fileUploadResult!= null && fileUploadResult.getUploadStatus())
{
stream=fileUploadResult.openResult();
using(ExcelPackage package= new ExcelPackage(stream))
{
int rowCount, i;
package.Load(stream);
ExcelWorksheet worksheet= package.get_workbook().get_worksheets().get_Item(1);
OfficeOpenXml.ExcelRange range=worksheet.Cells;
rowCount = worksheet.Dimension.End.Row - worksheet.Dimension.Start.Row 1;
try
{
for(i = 2; i <= rowCount; i )
{
Info(range.get_Item(i,1).Value);
accountNum = range.get_Item(i,1).Value;
custTable.AccountNum = accountNum;
custTable.insert();
}
info("Data inserted succesfully");
}
catch (Exception::Error)
{
ttsabort;
throw error("error here");
}
}// end using
}// end if
// end of Part 2
}// end if
}// end if
}
But it inserted the data in to DAT instead of USMF.
Kindly let me know why this happening? I like to insert in USMF
Pls give me more shed on this.
thanks!