Hi, Readers.
Last month I shared a new feature in Business Central 2021 wave 2 (BC19), Force sync of customer-specific extensions in online environments (ForceSync mode in Production Environment) I saw some questions after that, for example, if we keep the table no. and field No., will data be lost in Production Environment?
So in this post, I would like to briefly test some common scenarios, hope this will help.
Preparation
First, I prepared a new table and a new list page.
Table:
table 50100 "Lab Book"
{
Caption = 'Lab Book';
DataClassification = CustomerContent;
fields
{
field(1; "No."; Code[10])
{
Caption = 'No.';
DataClassification = CustomerContent;
}
field(2; Title; Text[30])
{
Caption = 'Title';
DataClassification = CustomerContent;
}
field(3; Author; Text[30])
{
Caption = 'Author';
DataClassification = CustomerContent;
}
field(4; Hardcover; Boolean)
{
Caption = 'Hardcover';
DataClassification = CustomerContent;
}
field(5; "Page Count"; Integer)
{
Caption = 'Page Count';
DataClassification = CustomerContent;
}
field(6; "Book Genres"; Option)
{
Caption = 'Book Genres';
OptionMembers = Classics,Fantasy,Horror,Comic;
}
}
keys
{
key(PK; "No.")
{
Clustered = true;
}
}
}
List page:
page 50101 "Lab Book List"
{
PageType = List;
UsageCategory = Lists;
ApplicationArea = All;
SourceTable = "Lab Book";
Caption = 'Book List';
layout
{
area(Content)
{
repeater(Group)
{
field("No."; Rec."No.")
{
ApplicationArea = All;
}
field(Title; Rec.Title)
{
ApplicationArea = All;
}
field(Author; Rec.Author)
{
ApplicationArea = All;
}
field(Hardcover; Rec.Hardcover)
{
ApplicationArea = All;
}
field("Page Count"; Rec."Page Count")
{
ApplicationArea = All;
}
field("Book Genres"; Rec."Book Genres")
{
ApplicationArea = All;
}
}
}
}
}
Then upload it to the production environment.
![](https://yzhums.com/wp-content/uploads/2021/10/image-76-1024x579.png)
![](https://yzhums.com/wp-content/uploads/2021/10/image-77-1024x487.png)
Add some test data.
![](https://yzhums.com/wp-content/uploads/2021/10/image-78-1024x266.png)
Using Force Schema Sync Mode.
![](https://yzhums.com/wp-content/uploads/2021/10/image-88.png)
![](https://yzhums.com/wp-content/uploads/2021/10/image-87.png)
PS: If you use Add Schema Sync Mode, there will be an error when the table schema is changed in a destructive way in an extension. (I don’t know why this error is displayed in Japanese)
![](https://yzhums.com/wp-content/uploads/2021/10/image-84.png)
Deployment failed. Errors: App ID : 8ed41111-a4d2-4d39-ad0e-5f1200490e8f Message : { 次のエラーにより、NAV 拡張機能 ‘Test Force Sync mode by ZHU YUN 19.0.0.1’ をアップグレードできませんでした: ‘Table Lab Book :: テーブル ‘Lab Book’ が見つかりません。削除するテーブルが一時的なテーブルである場合か、別のアプリへの移行によって移動する場合を除き、テーブルの削除は許可されていません。’。 } – Job Id : c4305ca2-5b2d-4726-ba5d-84eef4d03251
Could not upgrade the NAV extension ‘Test Force Sync mode by ZHU YUN 19.0.0.1’ due to the following error: ‘Table Lab Book :: The table ‘Lab Book’ cannot be located. Removing tables is not allowed unless they are temporary or are being moved by migration to another app.’.
![](https://yzhums.com/wp-content/uploads/2021/10/image-80-1024x548.png)
Change table name
![](https://yzhums.com/wp-content/uploads/2021/10/image-79-1024x315.png)
The data will be preserved.
![](https://yzhums.com/wp-content/uploads/2021/10/image-82-1024x411.png)
Change table ID
![](https://yzhums.com/wp-content/uploads/2021/10/image-89-1024x302.png)
The data will be preserved.
![](https://yzhums.com/wp-content/uploads/2021/10/image-91-1024x474.png)
PS: if you change the table ID, please don’t forget to generate a new permission set.
Package validation failed due to the following error(s): (1,13): error PTE0004: Table ‘50101’ is missing a matching permission set.
warning PTE0014: The XML file ‘/perm/file0_extensionsPermissionSet.xml’ should not contain Permissions or Permission Sets. Instead, use the dedicated AL object ‘PermissionSet’. – Job Id : 8255bfff-f36b-4208-ae55-a15291999ef9
![](https://yzhums.com/wp-content/uploads/2021/10/image-90-1024x546.png)
Change both table name and table ID
![](https://yzhums.com/wp-content/uploads/2021/10/image-110-1024x409.png)
![](https://yzhums.com/wp-content/uploads/2021/10/image-111-1024x307.png)
The data will be lost.
![](https://yzhums.com/wp-content/uploads/2021/10/image-112-1024x469.png)
Change field name
Rename fields including primary key.
![](https://yzhums.com/wp-content/uploads/2021/10/image-86-1024x437.png)
The data will be preserved.
![](https://yzhums.com/wp-content/uploads/2021/10/image-85-1024x490.png)
Change field ID
![](https://yzhums.com/wp-content/uploads/2021/10/image-92-1024x523.png)
The data will be preserved.
![](https://yzhums.com/wp-content/uploads/2021/10/image-93-1024x494.png)
Change both field name and field ID
![](https://yzhums.com/wp-content/uploads/2021/10/image-113-1024x452.png)
![](https://yzhums.com/wp-content/uploads/2021/10/image-114-1024x544.png)
The data will be lost.
![](https://yzhums.com/wp-content/uploads/2021/10/image-115-1024x490.png)
Change field type
Text -> Code, Text -> Boolean
![](https://yzhums.com/wp-content/uploads/2021/10/image-94-1024x521.png)
The data will be lost.
![](https://yzhums.com/wp-content/uploads/2021/10/image-95-1024x492.png)
Change Option to Enum
![](https://yzhums.com/wp-content/uploads/2021/10/image-96-1024x372.png)
The data will be preserved.
![](https://yzhums.com/wp-content/uploads/2021/10/image-97-1024x494.png)
Change Primary Key
![](https://yzhums.com/wp-content/uploads/2021/10/image-98-1024x345.png)
The data will be preserved. (please be careful that changing the primary key may cause many other problems)
![](https://yzhums.com/wp-content/uploads/2021/10/image-99-1024x492.png)
Increase field length
![](https://yzhums.com/wp-content/uploads/2021/10/image-100-1024x537.png)
The data will be preserved.
![](https://yzhums.com/wp-content/uploads/2021/10/image-101-1024x278.png)
Reduce field length
![](https://yzhums.com/wp-content/uploads/2021/10/image-102-1024x503.png)
If you reduce the length of a field by less than the length of the current data, then the data will be partially lost.
![](https://yzhums.com/wp-content/uploads/2021/10/image-103-1024x307.png)
Delete fields
![](https://yzhums.com/wp-content/uploads/2021/10/image-104-1024x510.png)
The data will be lost.
![](https://yzhums.com/wp-content/uploads/2021/10/image-108-1024x283.png)
Note: If you delete a field contained in the Primary Key, the data will all be lost.
![](https://yzhums.com/wp-content/uploads/2021/10/image-106-1024x698.png)
![](https://yzhums.com/wp-content/uploads/2021/10/image-107-1024x490.png)
Delete tables
The data will be lost.
![](https://yzhums.com/wp-content/uploads/2021/10/image-109-1024x475.png)
In summary
Action | Install | Data Loss |
Change table name | 〇 | ✖ |
Change table ID | 〇 | ✖ |
Change both table name and table ID | 〇 | 〇 |
Change field name | 〇 | ✖ |
Change field ID | 〇 | ✖ |
Change both field name and field ID | 〇 | 〇 |
Change field type | 〇 | 〇 |
Change Option to Enum | 〇 | ✖ |
Change Primary Key | 〇 | ✖ |
Increase field length | 〇 | ✖ |
Reduce field length | 〇 | △ |
Delete fields | 〇 | 〇 |
Delete tables | 〇 | 〇 |
END
Hope this will help.
Thanks for reading.
ZHU
コメント