Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Error while importing data from excel to some customized field of Sales Table error is"Field Sare order must be filled in"

(0) ShareShare
ReportReport
Posted on by 3,090

Errorwhileimportingdata.png

Hi Experts,

I wanted to import data to some customized fields to the Sales Table. Basically, I have added 6 fields new to sales table and tried to import data to these new fields from the excel sheet using X++ code. please check the above image with an error.

Best Regards,

Shabir 

  • Verified answer
    Shabir Ahmad Profile Picture
    3,090 on at
    RE: Error while importing data from excel to some customized field of Sales Table error is"Field Sare order must be filled in"

    Hi Gunjan Bhattacharyya,

    I import data using excel-Add-In function very easily because of the short of time developing report. But i will next time try to import using x++ code as well thanks a lot.

    Best Regards,

    Shabir  

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: Error while importing data from excel to some customized field of Sales Table error is"Field Sare order must be filled in"

    Hi Shabir,

    You are inserting into SalesTable without setting SalesId and the other mandatory fields. That's why you are getting the error. Do you have the values for customer account etc. saved in the excel file you are trying to upload?

  • Shabir Ahmad Profile Picture
    3,090 on at
    RE: Error while importing data from excel to some customized field of Sales Table error is"Field Sare order must be filled in"

    static void Esh_ReadExcel(Args _args)
    {
    
    SysExcelApplication application;
    SysExcelWorkbooks workbooks;
    SysExcelWorkbook workbook;
    SysExcelWorksheets worksheets;
    SysExcelWorksheet worksheet;
    SysExcelCells cells;
    COMVariantType type;
    
    int row=1;
    //Str Emp_Id,Emp_Name,Emp_Profile;
    FileName filename;
    SalesTable esh_ExcelUpload; //table buffer
        BRANCH branch;
        Target target;
        SALESMENNAME salesmenname;
        SMID smid;
        TgtCategory tgtcategory;
        TgtCatID tgtcatid;
        Channel channel;
    
    ;
    application = SysExcelApplication::construct();
    workbooks = application.workbooks();
    
    //specify the file path that you want to read
    filename = "C:\\TargetExcel.xlsx";
    
    try
    {
        workbooks.open(filename);
    }
    catch (Exception::Error)
    {
        throw error("File cannot be opened.");
    }
    
    workbook = workbooks.item(1);
    worksheets = workbook.worksheets();
    worksheet = worksheets.itemFromNum(1);
    cells = worksheet.cells();
    
    do
    {
        //read data from Excel
        row  ;
       // Emp_Id = cells.item(row, 1).value().bStr();
       // Emp_Name = cells.item(row, 2).value().bStr();
        //Emp_Profile = cells.item(row, 3).value().bStr();
        branch = cells.item(row,1).value().bStr ();
        target =  any2real(cells.item(row,2).value().toString());
        smid = cells.item(row,3).value().bStr ();
        channel = cells.item(row,4).value().bStr ();
        tgtcategory = cells.item(row,5).value().bStr ();
       tgtcatid = cells.item(row,6).value().bStr ();
        salesmenname = cells.item(row,6).value().bStr ();
       // info(strfmt('%1 - %2', Emp_Id, Emp_Name,Emp_Profile));
    
    
        type = cells.item(row 1, 1).value().variantType();
    
        //insert data into table
        esh_ExcelUpload.clear();
        esh_ExcelUpload.BRANCH      = branch;
        esh_ExcelUpload.Target    = target;
        esh_ExcelUpload.SALESMENNAME = salesmenname;
        esh_ExcelUpload.SMID      = smid;
        esh_ExcelUpload.TgtCategory    = tgtcategory;
        esh_ExcelUpload.TgtCatID = tgtcatid;
        esh_ExcelUpload.insert();
    }
    
    while (type != COMVariantType::VT_EMPTY);
    application.quit();
    }

    Please check the code 

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: Error while importing data from excel to some customized field of Sales Table error is"Field Sare order must be filled in"

    Hi Shabir,

    Can you share your code (which is throwing the error)?

  • Shabir Ahmad Profile Picture
    3,090 on at
    RE: Error while importing data from excel to some customized field of Sales Table error is"Field Sare order must be filled in"

    Hi Gunjan Bhattacharyya,

    I am importing data for new fields which i added to Sales table these are 6 fields added by me to Sales table. I am importing it from excel sheet.Still the issue is not resolved

    Best Regards,

    Shabir Ahmad

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: Error while importing data from excel to some customized field of Sales Table error is"Field Sare order must be filled in"

    Hi Shabir,

    Were you able to resolve this issue? If yes, please mark the answer as verified.

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: Error while importing data from excel to some customized field of Sales Table error is"Field Sare order must be filled in"

    Hi Shabir,

    Are you importing data into for the additional fields into existing SalesTable records or are you importing new data into SalesTable? From the error it looks like the field SalesId is not being populated.

    You can share your code so that we can take a look and try to figure out the issue.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,110 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,886 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans