Introduction:

This blog demonstrates how to modify the non-key fields with respect to the key fields.

Pre-requisites:

NAV 2017

Demonstration:

Generally, when modifying the records, the syntax used is

Record.FieldName := New_Value;
Record.MODIFY(TRUE);

In order to do modify the Key fields of the table, we need to know the order in which the keys are assigned.

To modify the primary key, the syntax used is Record.RENAME(Key1,Key2,Key3);

Where, Key1 corresponds to value that is supposed to be assigned to ‘No.’ field. Key2 corresponds to value that is supposed to be assigned to ‘LineNo.’ field. Key3 corresponds to value that is supposed to be assigned to ‘Leased to Driver No.’ field.

Even when the single key field is to be changed, all the key fields should be present in their sequential order. If there is any mismatch in the number of keys, NAV throws the following runtime error.

Note: Renaming operation is a costly operation. Creating a New record and Deleting the old record is faster as compared to Rename. In case where the performance is the requirement, the second method is preferred.

The post Modifying the Primary keys of records in NAV appeared first on CloudFronts - Microsoft Dynamics 365 | Power BI | Azure.