Friday, November 11, 2022

Dynamics 365 F&O - get the differences in values before update and after update in a table

public void update()

{

        EmployeeDataTable         modifiedBuffer = this;

        EmployeeDataTable         origBuffer = this.orig();

        boolean                             isStatusChange = false;


        var comparer = VersioningCompareRecordVersions::newTableId(tableNum(EmployeeDataTable));

        container changes = comparer.packChangedFields(VersioningChangeType::Updated, origBuffer, modifiedBuffer);

        // Show modified fields

        for (int i = 1; i <= conLen(changes); i++)

        {

            container changedField = conpeek(changes, i);

            FieldId fieldId = conpeek(changedField, VersioningCompareRecordVersions::posRelatedFieldId());

        }

        super();

}