Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Fields in a form's grid from temporary table are not populating

(0) ShareShare
ReportReport
Posted on by 12
  • Hana Xue Profile Picture
    Hana Xue Microsoft Employee on at
    Fields in a form's grid from temporary table are not populating
    Hi,
    I'm very happy to hear that your problem has been solved, and thank you for sharing. This is also very beneficial to other users of the forum. If you have any questions, welcome to the forum to discuss.
    Best Regards,
    Hana
  • Verified answer
    Community member Profile Picture
    Community member 12 on at
    Fields in a form's grid from temporary table are not populating
    Figured it out the issue.
     
    When repopulating the table records I have to link again the physical instance of the table to the current datasource buffer, then refresh the datasource.
     
    I created and made call to a new method in my form that does this, and now it's working.
     
    public void repopulateGrid(int _month)
    {
            delete_from tempTable;

        myClass.parmMonth(_month);
        tempTable = myClass.populateTempTable();

        MyTableTmp.linkPhysicalTableInstance(tempTable);
        MyTableTmp_ds.research();
    }
     
  • Suggested answer
    Community member Profile Picture
    Community member 12 on at
    Fields in a form's grid from temporary table are not populating
    The requirement of the form I created is to display the information for the customers' activities along with its monthly sales data.
     
    In order to accomplish this:
    1. I first created a temporary table setting its table type property to TempDB.
    2. Added my termporary table as datasource into my form.
    3. Override my form's datasource method init.
     
    The code of the init method.
        [DataSource]
             class MyTableTmp
        {
                     public void init()
            {
                myClass = new MyClass();

                             super();

                tempTable = myClass.populateTempTable();

                MyTableTmp.linkPhysicalTableInstance(tempTable);
            }
         }
       
    The object my class refers to a class I created that handles the business logic to insert records into my temporary table.
     
    This is code for the class method.
    public MyTableTmp populateTempTable()
    {
        MyTableTmp tempTable;
            smmActivities activityTable;
        smmActivityParentLinkTable linkTable;

            while select activityTable
                join linkTable
            where linkTable.ActivityNumber == activityTable.ActivityNumber
            && linkTable.ParentType == smmActivityParentType::Customer
            && activityTable.DataAreaId == curExt()
        {
                     CustTable custTable = CustTable::findByRef(activityTable.DataAreaId, linkTable.RefRecId);

            tempTable.ActivityNumber = activityTable.ActivityNumber;
            tempTable.ActivityTypeId = activityTable.TypeId;
            tempTable.RepsonsibleWorker = HcmWorker::find(activityTable.ResponsibleWorker).name();
            tempTable.CustAccount = custTable.AccountNum;
            tempTable.Name = custTable.name();
            tempTable.MySales = this.calcMySales(custTable);
                     tempTable.insert();
        }

            return tempTable;
    }
     
    Lastly, I added a custom filter in my form that allows the user to select the month. Then, I pass the month selected as a parameter into my class so it can calculate the average monthly sales of the customer and inserts that data into my temporary table.
     
    Every time that I select a different month an event handler, added into my class, is triggered so that it calls my form's datasource executeQuery method in order to first delete the table and then repopulate it again.
     
    My form's filter event handler method:
    [FormControlEventHandler(formControlStr(MyForm, MonthFilter), FormControlEventType::Modified)]
    public static void MonthFilter_OnModified(FormControl sender, FormControlEventArgs e)
    {
            FormDataSource fds = sender.formRun().dataSource("MyTableTmp") as FormDataSource;

            if (fds)
        {
            fds.executeQuery();
        }
    }
     
    The code for the executeQuery method.
    [DataSource]
     class MyTableTmp
    {
        public void executeQuery()
        {
                    int monthSelected = MonthFilter.selectionChange();

                    delete_from tempTable;

            myClass.parmMonthsOfYear(monthSelected);
            tempTable = myClass.populateTempTable();

                    super();
        }
    }
     
     
    I researched and tried out all solutions posted in the following links but none of them have worked out for me.
     
    I do recall back when I was programming in AX 2012 that it worked populating the contents of a form's grid that uses a temporary table.
     
    I kindly request your help to let me know both what I'm doing wrong and what I'm missing.

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,661 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,379 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans