Dynamics 365 Business Central: Convert permission sets into AL object (Conversion Tool)

Dynamics 365 Business Central

Hi, Readers.
Today, I would like to discuss how to convert permission sets in the previous version of BC into AL objects . (Before BC18.0)

As you might know, from Business Central 2021 Wave 1, Permission Sets are now AL objects.

Standard source code:

For more details: Entitlement, PermissionSet, and PermissionSetExtension (New AL objects)

If you open the local database directly, you will find a difference in the table contents of the Permission Set.
“dbo.Permission Set” in BC18.0 local database.

“dbo.Permission Set” in BC17.6 local database.

So, for permission sets in the previous versions of BC, can we converted them to AL files?
In the Dynamics 365 Business Central Launch Event 2021 release wave 1 held two days ago, Microsoft introduced a converting tool to do that.

For more details about the event: Some key information about Dynamics 365 Business Central Launch Event 2021 release wave 1

Let’s try it.

URL: Convert-PermissionSets.psm1

You can find descriptions in it.

.SYNOPSIS

Create AL PermissionSet objects that are identical to the existing permission sets from the database.

.DESCRIPTION

Reads all the permission sets from the specified database and creates PermissionSet AL objects with identical names and permissions

.EXAMPLE

Convert-PermissionSets -DatabaseServer localhost -DatabaseName W1 -Destination “.\NewPermissionSets”

.PARAMETER DatabaseServer

Database server from which permission sets will be read.

.PARAMETER DatabaseName

Database name from which permission sets will be read.

.PARAMETER Destination

The output directory.

The basic command is as following: You can modify the red parts as needed

Convert-PermissionSets -DatabaseServer localhost -DatabaseName W1 -Destination “.\NewPermissionSets”

For example: Run command

Convert-PermissionSets -DatabaseServer W1004408N201\BCDEMO -DatabaseName “Demo Database NAV (17-6)” -Destination “C:\Demo\NewPermissionSets”

Downloading Symbol: This may take a little time.

Quering Permissions:

Processing…

Writing File…

Completed.

You can now find the generated AL file in the folder.

For the finished conversion AL files, it may not be exactly correct and may need to be modified. This is similar to the Txt2AL tool.

PS:

1. This tool connects SQL Server by default using windows authentication and will report an error if the current user does not have permissions.

2. Since this tool only supports conversion in the local database, for the SaaS version, I tried exporting the database and restoring it locally. Then run the tool, but it failed.

Version: 15.2.39060.0

If you run the tools, errors will occur. So It may not be possible to use this tool for SaaS environments at this time.

Find more details: How to Export Database and Restore it on Local SQL Server.


3. The default folder “.\NewPermissionSets” is “C:\Windows\System32\NewPermissionSets

END

Hope this will help.

Thanks for reading.

ZHU

コメント

タイトルとURLをコピーしました