As this is my first post this year, I want to start this out by wishing you all a great new year. Actually I wanted to write about a completely different topic, but Waldo’s post a few days ago gave me an idea. And I personally like this idea so much that I’m happy to be able to write about it in my first post of this year.
In his blog post waldo has built a page to display the license information. This is especially interesting for consultants who don’t have Powershell available. So far so good.
Another gentleman named Neil Roberts has already built functionality in 2019 that can import licenses into Business Central OnPrem using a Powershell Runner.
If you are a diligent reader of Waldo’s blog, you may remember his post with the not-out-of-the-box information. In it, he described how consultants can access useful information in the WebClient.
A while ago, I have rebuilt a Record Deletion Tool in Business Central, which can be used to delete records from tables.
What Is the Admin Toolbox?
You’re probably wondering why I’m telling you all this stuff. I’ll tell you. I’ve combined all this stuff into one page called “Admin Toolbox”, so you have all the features under one hood:
- Record Deletion Tool
- Viewing of license information
- Import of licenses
- Not out of the box information for consultants
Currently this page is only for OnPrem, because license information can only be displayed OnPrem and for the license import DotNet is used. If there is enough demand, I can create a SaaS version without the license area.
But that’s not all. In addition, I have created a How To for consultants so that they can upload the app themselves without the help of developers.
How To Install the Toolbox
To allow consultants to use the app without the help of their developers, I compiled it for the different Business Central versions and made it available in a separate GitHub repository.
The readme of the repository describes the individual steps for the installation.
The source code is available in this GitHub repository. If you as a developer still want to make changes, you can do so there.
Currently the following object numbers are used by the Admin Toolbox:
- Codeunits 50000, 50001
- Enum 50000
- Table 50000, 50001
- Page 50000-50002
In the toolbox, the languages German and English are maintained.
How To Use the Toolbox
After successful installation you will find the toolbox under the search term “Admin Toolbox”.
The toolbox is divided into four areas:
- How To
- License Information
The link in the FastTab “How To” will take you directly to a How To Guide in my GitHub repository.
You can use the “View” field to control the visibility of the controls in the page. When you open the page, all controls are displayed at first. If you change the view to “License”, for example, only the license information and the corresponding PageActions are displayed.
Record Deletion Tool
The Tables area shows you all the tables in the system except the system tables. It also contains functionalities to delete records from these tables.
Part of the following descriptions were copied from Olof Simren’s original post for the Record Deletion Tool. He created the original version for Microsoft Dynamics NAV. I rebuilt the tool and added some new functions to it.
This data deletion tool is useful if you want to ‘clean’ a company from transactional data. It could for example be that you have been testing transactions in a company that you want to use for a go-live or you just want to have a clean company without transactions for a demo, training or testing session.
Use the PageAction “Insert/Update Tables”. This will populate the list with all the tables that are in the database. System tables are excluded here. If you afterwards add new tables you can run this function again to have them added.
After you used the function, the tables are now available in the list.
Then you go through and select the tables you want to delete records from by checking the “Delete Records” field. The PageActrion “Suggest Records to Delete” can suggest records for you to delete by providing you with these two options:
- Suggest all transactional records to delete
- Suggest unlicensed partner or custom records to delete
Use the first option to select the tables you typically want to delete records from when cleaning a company from transactional data.
Use the second option to suggest unlicensed partner or custom records to delete. This may be useful if you used a developer license in the system at some point and created records with that license. Now you want to switch back to the customer license and have errors in the system because of these still existing records.
Note: This second option must be used with the customer license. After you have suggested the records, you need to import the developer license to delete the records.
Note that the suggestion of tables may be incomplete or the logic faulty, but for my cases it worked. You should always check the suggested records manually afterwards and select additional tables if necessary!
Also note that I am not responsible if this suggestion selects something you don’t want to delete or skips something that you do want to delete.
Use the “Clear Records to Delete” function to remove all the selections.
When you are happy with the selection you press “Delete Records”. Business Central now goes through the tables and deletes all records from each of the selected tables. It might make sense to do a backup of the data before you do this.
I typically just copy the company before this step, so at least you have a company that can easily be restored or copy/paste data from.
Note that you can delete records either by running the deletion trigger or not. The default option is to delete records without using the deletion trigger.
Before the deletion is being executed, you get an information how many tables were marked for deletion.
After pressing “Yes”, you can watch the system do its work.
…and you get a success message after the operation has finished.
Note that the field “No. of Records” is updated after the operation.
After the records have been deleted it is recommended to review the tables that still have data in them to make sure you have not missed anything. The easiest way to do this is to just apply a filter on the “No. of Records” field to be <>0.
Use the “View Records” function to view the records in the tables. When selecting “View Records” the table will be run to show all the records and all the fields, like below.
When looking at the records it is typically quite easy to see if they should have been deleted or not. If the records has an entry number, document number, etc. it is most likely transactional data that should be deleted. The number of records in the table could sometimes also give you a hint if it should be deleted or not.
The next option when reviewing the remaining data is to use the “Check Table Relations” function. This function runs through all records and uses the field relations defined in the table “Field” in Business Central to validate the table relations. It does so by just looking if the related record is in the database or not.
Note that this only checks the very basic relations where a field has a table relation to a field in another table. This is similar to the table relations you find in the FactBox in the configuration worksheet. It does not check table relations that involve multiple fields or conditional table relations. But it is still a good check I think.
As this is a time consuming operation, you need to confirm before the table relations are being checked.
Watch the system work.
After the check on the table relations has run you can set a filter on the “No. of Table Relations Errors” to be <> 0. You should then see if there are any basic table relation errors.
If there are any errors you can make a drilldown on the number to see the errors.
These are the table relation errors in my example:
As mentioned above, the table relation check is only doing a basic check, so don’t rely too much on it. If you have a large amount of master data it might also take a while to run.
License Overview and Import
The area “License” shows you the license information. It is using the field “Text” from the table “License Information” to present you the information.
You can import a new license by using the “Manage” -> “Import License” function.
Select a new license file and be happy.
Links to Informational Tables
Find links to useful tables in the area “Information”. I used the links from Waldo’s blogpost.
By clicking on a link a new tab will be created that leads you to the page.
Hope you find this as useful as me.
Suggestions, ideas? Have fun with it!