Primary Key Update

Hello,

I’ve added accidentally 2 field to the Primary Key, that I can’t remove. If I try to revert the changes, I get this:


Microsoft Dynamics NAV Development Environment

The schema synchronization may result in deleted data. The following destructive changes were detected:

Table: 5847, Average Cost Calc. Overview
Field: 3, Valuation Date: Removed from primary key
Field: 31, Quantity: Removed from primary key

Examples of code to migrate data:

DataUpgradeMgt.SetTableSyncSetup(DATABASE::“Average Cost Calc. Overview”,[Upgrade Table Id],TableSynchSetup.Mode::[Mode]);

How can I restore the structure? I’m in a Test System, not live.

Thanks

Hi [mention:83f75ef5a2654d3196286e7b246d1b21:e9ed411860ed4f2ba0265705b8793d05] ,
If you just added field and havent used or put data in table then you can select Schronization Schema as force while comiling / save object.

Still i would suggest to keep a backup of data (if any in the table) before doing it , because with Force Schronization Schema if any data which does not fullfill the new field / key structure that data will be deleted.

1 Like

Hi,

Thank you for your reply, it helped me, with “Force” were updated.
What I wanted to try is to make this table sortable by default by “Valuation Date” Descending, but all the columns are fixed (not sortable). I’ve added as a Key to the Table and SourceTableView set to SORTING(Valuation Date) ORDER(Descending) but no effect.

Do you have any suggestions?

Hey [mention:83f75ef5a2654d3196286e7b246d1b21:e9ed411860ed4f2ba0265705b8793d05] ,
What you want to acheive by the sorting. Do you want sorted data in Page or you want to use the sorted data in code?
If you want to sort the data for page you dont need a key you can do that by page property Source table view and for the report you can add a new key with just the field valuation date and use that during code.

I’ve did what you said. I just want to be sorted in the Page. But in my page I can’t sort neither manually by “Valuation Date” or any other field.

pastedimage1476818813577v2.png

Which version is this? Remember that some of the previous builds had an error in which you couldn’t change the sorting in some listpages.

It could also be related to that the table you are using is temporary.

The version is 2015.

Can you change sorting of the page by clicking the other columns?

No, I can’t sort the page.