AX – D365FO – Get source record from a caller object

In this example I’ll show how to obtain the source record from a caller object.

Suppose you have a form A that calls form B.

In Form B you want to know what is the data source of the Form A and if it’s a VendTable you want to retrieve the AccountNum field

 VendTable vendTableLocal;
        switch (element.args().record().dataSource().Name())
        {
            case 'VendTable':
                vendTableLocal = element.args().record() as VendTable;
                    break;
            default:
                break;
        }

        if(vendTableLocal)
        {
            while select al0VendorSearchCriteriaLocal
            where al0VendorSearchCriteriaLocal.AccountNum == vendTableLocal.AccountNum
            {
                element.ExpandAndSelect(al0VendorSearchCriteriaLocal.VendorActivityRefRecId, formFirstRun);
            }
            ;
        }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s