Power Community

Power Community

COPY PROFILES : Things to really know

With Dynamics 365 Business Central, it is possible to copy profiles within an environment. This is done internally by an internally developed platform component that obey to the following pillars:

  1. Copy profiles work flawlessly when there are no page customizations.
  2. Copy profiles work flawlessly all the time with page customizations except when few hitting constraints.

Copy profile born with the intention of copying profiles and all its customizations made by users without the intervention of a developer.

This is clearly reported by the tool tip since ever. E.g. See below version 18.6, for example. The key point here is the “any page customizations made by users for this profile”.

 

This can be then a matter of debate, then, since it was born with the intent of copying page customizations made by users and not considering the exotic and complex (for example directives) page customizations that could be made by developers.

This gives me the opportunity to introduce the first constraint.

1. Pre-Processor Directives

This has been reported officially here

Preprocessor Directives in AL – Business Central | Microsoft Docs

These documentation amendments have been added and are valid since 19.1 and onwards.

In earlier versions (better 18.6 and backwards) it was not even handled and throw a runtime error.

The ones below were original repro steps logged for 18.5. Just FYI and record.

Environment information:

Version: Business Central 18.5 (Platform 18.0.29486.30325 + Application 18.5.29545.30344)

  1. Create a profile with a pagecustomization 
  2. Create a pagecustomation which contains a pragma.
  3. Try to create a copy of this profile, no error is given.
  4. Try to run the troubleshot, an error is given which is shown in the image on the first page. Or try to change the description of the copied profile and leave the card page. An error will occur.

And below the Description of the issue reported

On the page “Profiles(Roles)” you are able to create a copy of a profile.

You can create a copy of a profile which has page customizations. When you copy a profile with a pagecustomization that contains pragma, the copy is created. However when you try to troubleshoot the profile or try to change the description you will see that the copied profile does not compile.
The profile is created without the last closing bracket }

Now the platform changes to cope with this issue – available since 18.7 and 19.1 – were the following (from the Pull Request description)

Description

Merged PR […]: [Designer] Handle gracefully preprocessor directives in AL code

Problem:
When the designer creates NavDesignerObjects based on the syntax nodes for the AL code loaded, some of the trivias (including directives and/or end of lines) are lost. The designer is then working with invalid AL code.

Solution:
The designer isn’t meant to work with directives, so we should just ignore/remove them when possible (#pragma, #region, #endregion) and fail when not supported (#if, #elif, #define, etc).

Note:
The solution here targets User Personalization and Profile Configuration (including profile copy) and doesn’t cover the scenario with a DEV extension (roundtrip from VS Code) because it would probably be too restrictive […].

There are other 2 main constraints here that needs to be considered

2. Target ProfileCustomization name cannot exceed 30 characters (ergo source profile customization should not exceed 21 characters)  

You might see this error logged in the Application Log, when failing to copy a profile:

Category: Designer

Message Error(s) compiling Configuration designer extension — Details:Error – AL0305: The length of the application object identifier ‘MS___””PageCustWithoutDirectives””‘ cannot exceed 30 characters. (Location: ‘Page customization targeting ‘Another Role Center”)

This error comes from the copying routing that clone profiles and, as per initial preamble, it was meant with page customizations generated by users through personalization feature (whom name is not exceeding 21 characters).

This happens because of the platform is trying to keep the same internal syntax for the copied page customizations.

So, now, if you have in your custom extension a profile customizations whom name (aka application object identifier) is grater than 21 characters then you will fumble into this and UI will surface the generic error ‘Profile cannot be copied’ (or sort of) and subsequently an error in the Application Log as per the follow

Category: Designer

Message Failure copying profile with ID ‘DT-PC’ and App ID ‘592261bc-56ac-4dd8-bf85-bdabc5421a5b’

The solution to this constraint is to change Page Customizations coming from Apps with a Name that is less or equal 21 characters.

3. MAX One Page Customization per page

Internally, there is a check that is validating the uniqueness of page customization target (aka page name) per profile.

This happens because of there is no support for merging multiple page customizations into one in the copied profile. As all merges, this will be easily error prone.

If there are multiple page customizations belonging to the same page object, then, the profile cannot be copied.

The solution to this constraint is to make sure that there are no multiple page customizations belonging to the same page object within the same profile.

- Advertisement -spot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img

Latest News

3 advantages of composable applications to empower supply chain network innovations

Manufacturing supply chains are experiencing a post-pandemic paradigm shift. As business models evolve to solve market disruptions, such as...
- Advertisement -spot_img

More Articles Like This

- Advertisement -spot_img