Recently one of my customer asked me to add few more fields on primary key and I was looking at the customer like he asked something which is daunting task to be done with business central as everybody aware of that we can not change the primary key fields when table is already having data as while deploying the app it throws an error as below
Even I tried using Force sync also but it is still failing to deploy the app as this is breaking change for the app.
Now question is how to do this and overcome from such situation as your customer is behind you to do that.
To make it work we need to use ObsoleteState and ObsoleteReason that means we need to make your table obsolete and create a new table with new primary key and change the references in all those object where the object is referred.
To make the table obsolete mention the property as below.
Obsolete property value
Not obsolete. This is the normal/default setting.
Will become obsolete in a future version.
Has been made obsolete.
After making above table obsolete created new table with the new primary key.
Next point is how to transfer data in the new table .
To transfer data from obsolete table to new table used Installed code unit . Additionally you can use temporary table to update data from old table to new table.
If you would like to learn more about ObsoleteState Property then visit here.
Do you remember this post where in I explain the use of showmycode property from app.json file. With this property we have only one option either we allowed to debug and download your app or vice versa.
Now with new version of AL language this property has been deprecated and new property has been introduced resourceExposurePolicy where in we get leverage to control your app from debug ,download the app file.
This property will be automatically added when new project is created as below.
If you can see in this property we have three options which can be used to control the app and your IP.
AllowDebugging :- Allow to control the debugging of your app when it is published. The default setting is true.
AllowDownloadingSource :- Allow to control the download of your app source code .The default setting is false.
IncludeSourceInSymbolFile: Allow to control symbol to be included in the source code of package. The default setting is false.
Can I add resourceExposurePolicy and showmycode property together ?
With the introduction of this new property in app.json file we can not use showmycode property as it will show an error and warning as below.
Hopefully this will help us to control our IP and provide more security on our app.
This week one of the customer post few transaction and found that one of the field user enter some wrong information. In ideal situation user need to reverse the transaction and post correct transaction which is safest approach.
But do you remember those old days where we have access to the table and can modify the data but with business central this ability no more available . I just build one small extension to modify the data in the table where in we can modify the posted data .
Important: It is not recommended to change data in the tables directly as it will cause inconsistency in database and make database vulnerable.
Just check following video to check small amount of work I did.