D365 Business Central : Converting BC PermissionSet XML to PermissionSet Object

Since BC18, we can define PermissionSet object on our app to replace the PermissionSet XML. The PermissionSet object is much simpler and clear to use than the XML. If you already using XML in your app, you will eventually need to convert it from XML to Object, then maps all your users usage of the old Xml PermissionSet to the new PermissionSet object. Currently, there is no standard way to help us convert it easily. Here comes the NAB AL Tools extension to the rescue.

If you have installed the NAB AL Tools, there is a “Convert to PermissionSet objects” tool that you can use. Below is the description of the tool.

NAB: Convert to PermissionSet object
Converts a PermissionSet defined in XML into a PermissionSet object.

The user is prompted to supply a prefix that will be used for the object names. The default value is fetched from the first mandatoryAffixes in the AppSourceCop.json, if available.
The prefix is added to the old RoleID as a suggested Name for the new PermissionSet object.
The old RoleName is added as a suggested Caption for the new PermissionSet object.
The Name and Caption is editable before conversion starts.
Some validation tests are being done on the provided names and captions.
Max length
Non-empty
Some illegal characters
etc.
After the PermissionSet objects has been created, the old Xml PermissionSet files are deleted.
An upgrade codeunit is created that maps the usage of the old Xml PermissionSet to the new PermissionSet object.

NAB AL Tools

Excellent. Let’s try using it.

One of the prerequisite to use this tool is to have AppSouceCop.json file on your PTE app (even though you don’t need it for your app). If you don’t have the file, you will get the missing file error.

It’s easy enough to create the file, so let’s create a blank json file. You can delete it after the conversion.

Run the “NAB: Convert to PermissionSet objects”.

You can specify the Object Prefix if needed. Otherwise, press Enter to confirm.

You can specify the Object Name and Caption here. Then press OK.

That’s it. The tool will delete the old PermissionSet XML, create the PermissionSet object, and create the upgrade codeunit. When you publish the app, the upgrade codeunit will take care of remapping the user permission set to the new one.

New Permission Set
UpgradeCodeunit

Easy ! There are others function inside NAB AL Tools, such as Renumber AL Objects, create translation XLF, generate tooltip, etc. Be sure to check it out.

thatnavguy

Experienced NZ-based NAV Developer and Consultant with 15+ years of experience leading multiple IT projects, performing business analyst, developing, implementing, and upgrading Dynamics NAV and Business Central. Passionate to deliver solution that focuses on user-friendly interface while keeping high standard of compliance with the needs.

You may also like...

3 Responses

  1. theschitz says:

    Great post! So nice to see that you picked up on new features. The AppSourceCop.json error is beeing tracked in issue #290 (https://github.com/jwikman/nab-al-tools/issues/290). It’s not going to be a requirement for much longer 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *