Monday 21 April 2014

Resolving Ctrl+F5 Error on creation of Item Master in AX2012.

Solution for Ctrl+F5 Error on creation of Item Master in AX2012.

Error: Cannot edit a record in Items(InventTable).
The values displayed in the form are not current, so an update or deletion

cannot be made. To view the current values, on the command menu, click
Restore or press CTRL+F5.

As the error message says, this error is due to an update conflict. when we
try to update the master data in some business process and this call is from
the form, the rec-version on the form is different from the current
rec-version in DB. Hence system will throw error.

To resolve this kind of issues, we need to refresh and reread the calling
formDataSource.


Here is the code.

// NS by Mallik 10/04/2014
    FormRun         formRun;
    FormObjectSet   formObjSet;
    int             i;
    InventTable     linventTable;
// NE by Mallik 10/04/2014
// NS by Mallik 10/04/2014
    // refresh and reread inventTable datasource if exists in form
    if (this.isFormDataSource())
    {
        formRun = this.dataSource().formRun();
        for (i=1; i<= formRun.dataSourceCount(); i++)
        {
            if (formRun.dataSource(i).cursor() is InventTable)
            {
                formObjSet = formRun.dataSource(i);
                linventTable = formObjSet.cursor() as InventTable;
                break;
            }
        }
        if (!linventTable)
        {
            linventTable = InventTable::find(this.ItemId, true);
        }
        if (linventTable)
        {
            if (formObjSet)
            {
                formObjSet.refresh();
                formObjSet.reread();
            }
        }
    }
// NE  by Mallik 10/04/2014

Update NuGet package to new MS D365FO version

1. Import the NuGet package files from LCS for that particular version please take the PU version files only. a. Goto LCS-->Asset Libra...