web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Refresh a form after insert data in a table

(0) ShareShare
ReportReport
Posted on by

Hey Guys,

first of all i'am new at AX.

I want refresh a form after insert data in a table. I insert data from a excel sheet that i read.
After the data is insert i want that the from is refresh the table.

Code:

....

do
    {
        row++;

        this.readRow(row, cells); // read the row and cells in the excel sheet
        this.insert();                    // insert the data from the excel sheet

        type = cells.item(row+1, 1).value().variantType();
    }
    while (type != COMVariantType::VT_EMPTY);
    / / it is possible to refresh the table/form here ?
    application.displayAlerts(false);
    application.quit();
    
thanks for any help.

greetings

Felix

*This post is locked for comments

I have the same question (0)
  • XB Profile Picture
    1,875 on at

    You need to executeQuery of your datasource after insert all Data.

    YourDataSourceName_ds.executeQuery()

  • Community Member Profile Picture
    on at

    Thanks for your answer.

    But it does not work.

    Error: The field is not in the table.

  • XB Profile Picture
    1,875 on at

    where is you code set ,on class or on the form?

  • Community Member Profile Picture
    on at

    in the class, i want that the table/from is refresh after the insert so i write this behind the while loop for the read and insert in to the table

  • Mea_ Profile Picture
    60,284 on at

    Hi Felix Schneider,

    Could you please provide more details like exact error message and code that you wrote.

  • Community Member Profile Picture
    on at

    Hey ievgen Miroshnikov,

    public void run (boolean _onlyTest)

    {

       SysExcelApplication             application;

       SysExcelWorkbooks               workbooks;

       SysExcelWorkbook                workbook;

       SysExcelWorksheets              worksheets;

       SysExcelWorksheet               worksheet;

       SysExcelCells                   cells;

       COMVariantType                  type;

       int                             row;

       ;

       application     = SysExcelApplication::construct();

       workbooks       = application.workbooks();

       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();

       // Excel lesen und alle Zeilen verarbeiten

       do

       {

           row++;

           this.readRow(row, cells);

           this.insert();

           type = cells.item(row+1, 1).value().variantType();

       }

       while (type != COMVariantType::VT_EMPTY);

       //salesTableImpor_ds.executeQuery();

       //Excel Anwendung schließen

       application.displayAlerts(false);

       application.quit();

    }

    This is my run method and after the insert i want the refresh.

    After compile with the code from Javier Biesa the the error message was:

    The field is not present in the table.

    thats all

    Thanks for your answer.

  • XB Profile Picture
    1,875 on at

    Or you set this line "salesTableImpor_ds.executeQuery();" on form  or you need to pass throught parameters the dataSource to the class an execute in the class

  • Community Member Profile Picture
    on at

    where i set this line of code to the form ?

  • XB Profile Picture
    1,875 on at

    after call your yourclass.run() method

  • Community Member Profile Picture
    on at

    i dont call my class in the form there are only classDeclaration and init.

    The myclass.run() is call from a button in the form that starts the import and after the import is finished i will that the from is refreshing.

    Thanks for your help.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans