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 :
Finance | Project Operations, Human Resources, ...
Unanswered

Problem with getting args().record()

(0) ShareShare
ReportReport
Posted on by 843

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
    237,972 Most Valuable Professional on at

    Which line of code is throwing the error?

  • Shooowtek Profile Picture
    843 on at
    [quote]

    Which line of code is throwing the error?

    [/quote]

    7266.error.png

  • Martin Dráb Profile Picture
    237,972 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
    843 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
    237,972 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

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 456 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 429 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans