web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

[Upgrade CodeUnit] Handle Key/Field deletion

(0) ShareShare
ReportReport
Posted on by 217

Hi,

I'm performing some upgrade tests.

When I delete a table key, or when I delete/rename a table field during the Sync I get this error:

 An unsupported key change was detected. Keys cannot be changed, removed, or reordered. New keys can only be added 
to the end of the list.


Is there a way to handle this kind of error ? Or will it be possible to perform table field/key deletion from a version to the next ?

Thanks for your help!

Business Central W1 13.0 (25242)

AL Language v 2.0.48254

Categories:
  • Verified answer
    Stefano Demiliani Profile Picture
    37,172 Most Valuable Professional on at

    In a production environment, you cannot do that. If your extension was synched to a tenant, then your next version of the extension should be backward compatible.

    In the sandbox you can use SchemaUpdateMode: "recreate" from VS Code (you will loose data), but on production you should target the old table as Obsolete (with the 'ObsoleteState/Reason' properties) and then recreate a new table with the new keys. Then, in upgrade codeunit you have to move data from the old to the new table.

  • jdecottignies Profile Picture
    217 on at

    Hi,

    Thank you for your answer.

    I've just tested by only setting a field I want to delete as "ObsoleteState=Removed". It's working as I wanted.

    Could you tell me what the "Pending" value means ? Is it a state which is here to prevent user that in a future version this field will not be accessible anymore ?

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,172 Most Valuable Professional on at

    Pending: the element will be obsolete in a future release. This setting has no effect on the current use of the table, field, or key in code.

    Obsolete or Removed: the element is not deleted from the database; however, references to the the element in code are only allowed in upgrade codeunits. References from other objects will result in a runtime error.

  • jdecottignies Profile Picture
    217 on at

    Thanks for the precisions :)

    So in this case, it's not possible to keep my ID .. ? I mean if  I was arrived at the end of the range I earned, I delete a table for a next version, I have to earn one more ID to be able to publish an update ? It's the same for the fields IDs.

    Does developers have to predict in the project tree a folder like "ObsoleteObjects" that keeps all removed objects from the extension ?

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,172 Most Valuable Professional on at

    In the cloud you don’t have to think about object IDs, they’re free.

    Regarding project tree, there’s no a written rule. You can move the Obsolete in a new folder or not. What counts here is that when a field or table has ObsoleteState set, you ( or also who writes a dependent extension) cannot use this field.

  • jdecottignies Profile Picture
    217 on at

    Ok, thank you a lot for your answers! :)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans