web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Error Creating Custom Profile from with AL business central

(6) ShareShare
ReportReport
Posted on by 111

Hello everyone,

I’m working on Business Central v27 (cloud), and I’m trying to create a custom profile programmatically from the existing ‘RAPIDSTART SERVICES’ profile using an Install Codeunit.

Here’s the code I’m using:

When I run this, I get the following error:

 

The profile with the ID 'IFTAM' and AppId '{xxxx-xxx-xx-xxx}' cannot be created, because the specified AppId is different from the empty GUID.

And another question is profile.Copy(profileRapidStart); gonna do the same as the button "copy profile.." :
I have the same question (0)
  • Suggested answer
    Gregory Mavrogeorgis Profile Picture
    992 Super User 2026 Season 1 on at
    Hi,

    You’re getting that error because you’re inserting a new record with the same non-empty AppId as the source profile (“RAPIDSTART SERVICES” comes from the Base App).

    Business Central won’t let your extension create a profile that is “owned” by another app. Profiles you create at runtime must be tenant customizations → i.e., the App ID must be empty (all zeros) and “Published As” must be Tenant Customization.

     Read from All Profile, insert into Profile and clear the app fields

    codeunit 90902 "IFTAM Install"
    {
        trigger OnRun()
        begin
            CreateProfile();
        end;
        procedure CreateProfile()
        var
            SrcAllProfile: record "All Profile";
            NewProfile:    record Profile;
        begin
            if SrcAllProfile.Get('RAPIDSTART SERVICES') then begin
                NewProfile.Init();
                // copy the bits you want from the source
                NewProfile.Validate("Profile ID", 'IFTAM2');
                NewProfile.Validate(Description, 'Profile for IFTAM Integration');
                NewProfile.Validate("Role Center ID", SrcAllProfile."Role Center ID");
                NewProfile."Disable Personalization" := SrcAllProfile."Disable Personalization";
                // VERY IMPORTANT: make it a tenant customization (no app ownership)
                Clear(NewProfile."App ID");
                NewProfile."App Name" := '';
                NewProfile."Extension Name" := '';
                NewProfile."Published As" := NewProfile."Published As"::"Tenant Customization";
                NewProfile.Insert(true);
            end;
        end;
    }
    Notes:
     

    Use “All Profile” only to read an existing profile (it’s a union over app/tenant profiles).

    • Insert the new record into “Profile” (the insertable table).

    • Clearing "App ID" (and related fields) and setting "Published As" is what resolves the error.

     
    If you have found it useful please mark it as verified
  • El Mehdi Taher Profile Picture
    111 on at

    Hi Gregory Mavrogeorgis,

    I tried adapting your suggestion, but since the "All Profile" table has three primary keys, the Get didn’t retrieve the record, so I used Reset() and SetRange() to get the source profile instead.

    Here’s the adjusted part I used:

    procedure createProfile()
    var
        profileNewRec: record "All Profile";
        profileSrcRec: record "All Profile";
    begin
        profileSrcRec.Reset();
        profileSrcRec.SetRange("Profile ID", 'RAPIDSTART SERVICES');
        if profileSrcRec.FindFirst() then begin
            profileNewRec.Init();
            profileNewRec.Validate("Profile ID", 'IFTAM2');
            profileNewRec.Validate(Description, 'Profile for IFTAM Integration');
            profileNewRec.Validate("Role Center ID", profileSrcRec."Role Center ID");
            profileNewRec."Disable Personalization" := profileSrcRec."Disable Personalization";
            Clear(profileNewRec."App ID");
            profileNewRec."App Name" := '';
            // profileNewRec."Extension Name" := '';
            // profileNewRec."Published As" := profileNewRec."Published As"::"Tenant Customization";
            profileNewRec.Insert();
        end;
    end;
    
     

    However, when I tested it, the app unfortunately crashed during execution — no clear AL error message, just a session crash.

    And I can't find fields "Extension Name" and "Published As"?

     

  • Suggested answer
    YUN ZHU Profile Picture
    99,084 Super User 2026 Season 1 on at
    Hi, I think you can try two things.
    1. Refer to the standard code below for Copy Profile instead of inserting Profile directly.
    2. First copy one on the page, and then try inserting the value based on it.
     
    Hope this can give you some hints.
    Thanks.
    ZHU
  • Suggested answer
    OussamaSabbouh Profile Picture
    12,878 Super User 2026 Season 1 on at
    Hello,

    The error happens because the profile you’re creating inherits the Base App’s AppId, while your extension expects an empty GUID for tenant-scoped profiles.
    You can’t copy a base profile programmatically in an Install codeunit.
    Use a Profile object in AL (e.g., RoleCenter 9021) instead, or copy it manually in the client and export/import the package.
    profile.Copy(profileRapidStart) only copies table fields, it’s not the same as the “Copy profile…” action in the client, which also handles page customizations and AppId correctly.

    Regards.
    Oussama
  • Verified answer
    El Mehdi Taher Profile Picture
    111 on at

    Solution Found

     

    I discovered that the issue was caused by trying to create a new profile based on an existing system profile (“RAPIDSTART SERVICES”), which isn’t allowed directly because it belongs to another app (the Base App).

    To fix this, I created a procedure that copies the existing profile into a new tenant-owned one using the "Conf./Personalization Mgt." codeunit:

     
    procedure CreateProfile()
    var
        profileNewRec: Record "All Profile";
        profileSrcRec: Record "All Profile";
        ConfPersonalizationMgt: Codeunit "Conf./Personalization Mgt.";
    begin
        profileSrcRec.Reset();
        profileSrcRec.SetRange("Profile ID", 'RAPIDSTART SERVICES');
        if profileSrcRec.FindFirst() then begin
            ConfPersonalizationMgt.CopyProfileWithUserInput(profileSrcRec, profileNewRec);
            if profileNewRec.Get(profileNewRec.Scope, profileNewRec."App ID", profileNewRec."Profile ID") then
                Message('Profile %1 created successfully.', profileNewRec."Profile ID");
        end;
    end;

    This uses the built-in CopyProfileWithUserInput method to safely duplicate an existing profile while ensuring the new one is registered as a tenant customization (with an empty App ID).

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,946 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,177 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 555 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans