Exporting Permission Sets
Permission sets that exist in Dynamics 365 Business Central can be exported and packaged for your extension directly from the client, instead of defining XML by hand.
To export permission sets from Dynamics 365 Business Central
- In Dynamics 365 Business Central, search for Permission Sets, and then choose the relevant link.
- On the Permission Sets page, choose the permissions that you want to export, and then choose Export Selected Permissions.
- In the Export Permission Sets dialog, choose to export permission sets only for the application, only for the tenant, or for both.
- Save the file to your extension folder.
- Delete the permission sets from Dynamics 365 Business Central.
You can generate a permission set file which contains permissions to all the files in your extension. This will make it easier to start setting up permissions for your app. You can do this by simply creating an extension with some objects as described below.
To export permission sets using Visual Studio Code
- In Visual Studio Code, open your extension with objects; pages, reports, tables, queries, codeunits, and/or XMLports.
- Open the command palette using the
Ctrl+Shift+Pkeys and select the AL: Generate permission set containing current extension objects command.
If you do this repeatedly, Visual Studio Code will probe for overwriting the file, there is no support for merging manual corrections into newly generated content.
- Publish the app.
Now, you have the XML file with default permissions to all your objects.
Example from Visual Studio Code
The following example illustrates the generated .xml file from MyProject which contains a table with objectID 50106 and two object types are generated;
The maximum length of the RoleID attribute is 20 characters. If the RoleID exceeds this length, then the XML schema validation fails and the corresponding permission set file is not included in the resulting app package. You will get a warning in the Visual Studio output panel.
<?xml version="1.0" encoding="utf-8"?> <PermissionSets> <PermissionSet RoleID="MyProject" RoleName="MyProject"> <Permission> <ObjectID>50106</ObjectID> <ObjectType>0</ObjectType> <ReadPermission>1</ReadPermission> <InsertPermission>1</InsertPermission> <ModifyPermission>1</ModifyPermission> <DeletePermission>1</DeletePermission> <ExecutePermission>0</ExecutePermission> <SecurityFilter /> </Permission> <Permission> <ObjectID>50106</ObjectID> <ObjectType>1</ObjectType> <ReadPermission>0</ReadPermission> <InsertPermission>0</InsertPermission> <ModifyPermission>0</ModifyPermission> <DeletePermission>0</DeletePermission> <ExecutePermission>1</ExecutePermission> <SecurityFilter /> </Permission> </PermissionSet> </PermissionSets>
Object type mapping
The mapping of object types in the XML such as
<ObjectType>0</ObjectType> generated from Visual Studio Code is the following: