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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Problem with getting args().record()

(0) ShareShare
ReportReport
Posted on by 845

Hello,

I created a form that has InventTrans as the main datasource. From this form, I run the standard ProdTableCreate form :)

The requirement is that the ProdTableCreate form, when opened, is already populated with values from the selected line from the InventTrans form. Everything works OK, the form is populated with values, it creates a production order, but I always get the well-known error "Object reference not set to an instance of an object." at the end of steps.

I did some debugging and the error appears in the standard refreshCaller method at common_ds.research(). When executing the method, the common_ds variable has the null value..
Can anyone suggest what I am doing wrong?

standard refreshcaller() method:

 void refreshCaller()
    {
        Common         common;
        Common         commonDim;
        FormDataSource common_ds;
        FormDataSource commonDim_ds;

        if (element.args().dataset() == tableNum(SalesLine))
        {
            common      = element.args().record();
            common_ds   = FormDataUtil::getFormDataSource(common);

            common_ds.reread();
            common_ds.refresh();

            commonDim       = common.joinChild();

            if (commonDim.TableId == tableNum(InventDim))
            {
                commonDim_ds    = FormDataUtil::getFormDataSource(commonDim);

                commonDim.data(InventDim::find(prodTable.InventDimId));
                commonDim_ds.setCurrent();
            }
        }
        else if ( element.args().record() )
        {
            common_ds   = FormDataUtil::getFormDataSource(element.args().record());
            common_ds.research();
        }

init() method extension:

 public void init()
    {
        
        InventMovement  callerMovement;
        Object          callerFormObject;
        ProdTable       prodTableLocal;
        ProdIProdTableDefaultValuesProvider prodTableDefaultValuesProvider;

        next init();
  
        if (this.args() && this.args().caller())
        {
            callerFormObject = this.args().caller();

            switch (this.args().dataset())
            {
                case (tablenum(InventTrans))   :
                    callerBuffer = this.args().record();
                    break;

                default:
            }
        }
    }

refreshCaller() method extension:

  void refreshCaller()
    {
        Common         common;
        Common         commonDim;
        FormDataSource common_ds;
        FormDataSource commonDim_ds;

        if (this.args().dataset() == tableNum(InventTrans))
        {
            common      = this.args().record();
            common_ds   = FormDataUtil::getFormDataSource(common);

            common_ds.reread();
            common_ds.refresh();

            commonDim       = common.joinChild();

            if (commonDim.TableId == tableNum(InventDim))
            {
                commonDim_ds    = FormDataUtil::getFormDataSource(commonDim);

                commonDim.data(InventDim::find(prodTable.InventDimId));
                commonDim_ds.setCurrent();
            }
        }   

        next refreshCaller();
    }

I have the same question (0)
  • Martin Dráb Profile Picture
    239,471 Most Valuable Professional on at

    Which line of code is throwing the error?

  • Shooowtek Profile Picture
    845 on at
    [quote]

    Which line of code is throwing the error?

    [/quote]

    7266.error.png

  • Martin Dráb Profile Picture
    239,471 Most Valuable Professional on at

    OK, so the record isn't associated with a form data source. Do you have any record at all (in 'common' variable)?

  • Shooowtek Profile Picture
    845 on at

    I don't really understand.

    In the variable 'common' should be the actual args().record() from the caller form source.

    If I run the ProdTableCreate form, from a form with InventTrans source, should there be an actual passed record in args().record(), which is then passed to the 'common' variable?

    I don't understand why in my method extension I could pass args().record() to the variable 'callerBuffer' , but in the refreshCaller() method it doesn't work to the variable 'common'?

  • Martin Dráb Profile Picture
    239,471 Most Valuable Professional on at

    Well, you can keep speculating or start analyzing the situation. I would do the latter. Even if you think that there should be a record in the 'common' variable, there is a huge difference between thinking and knowing for sure.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 622

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 532 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 430

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans