AX – D365FO – Change data in calling datasource

formDataSource  formDataSource;
formRun         formRun;
salesTable      salesTable;
int             i;


// Change data in calling datasource

if(element.args() && element.args().caller() && element.args().caller().handle() == className2Id('formRun'))
    {
        formRun = element.args().caller();
        for (i = 0; i <= formRun.dataSourceCount(); i++)
        {
            formDataSource = formRun.datasource(i);
            if (formDataSource && formDataSource.table() == tablenum(salesTable))    // Search for specific table
            {
                salesTable = formDataSource.cursor();
                break;
            }
        }
        if(salesTable)
        {
            // Update data
            salesTable.PurchOrderFormNum = "Some value";
            salesTable.update();
        }
    }

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