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 :
Customer experience | Sales, Customer Insights,...
Suggested Answer

How to make the Canvas App id constant across environments?

(0) ShareShare
ReportReport
Posted on by 115

Hi,

I have an embedded canvas app in my development enviroment. When I export this app as a package and import it in my test environment, the App ID is getting changed. Because of this, I need to manually change the App ID in the form where I am using it. Is there any way to export the app with the same ID?

Thanks,

Madhan

I have the same question (0)
  • SergioMarques Profile Picture
    Microsoft Employee on at

    Hi Madhan,

    In practice, you shouldn't need to change the App Id in order for the embedded canvas app to work.

    Are you facing any specific error when you don't change it?

    Additionally, the user you are using when opening the form is a system admin? If not, can you check if the user has Organization level read permission to an entity called "Canvas App"?  

    Let me know the result of the testing and any feedback from this.

    Thank you.

  • Suggested answer
    Jelle_v Profile Picture
    45 on at

    In my experience, when extending a modeldriven app with a canvas app, it is to provide some custom functionality. Therefore we start in our DEV organization. Creating the canvas app also in the DEV organization, causes the embedded canvas app to refer to the canvas appid of the DEV organization.

    Deploying both the modeldriven as the canvas app to another organization will generate new appids. When you test the embedded canvasapp, the initial canvas app is shown (from the dev environment) and seems fine.

    Since the canvas app is interacting back to the modeldriven app trough the "ModelDrivenFormIntegration", it updates my DEV organization.

    This is not the intended behaviour.

    I wrote a plugin that copies the correct appid(from a env variable) to a custom appid field on crate of my record. The canvasapp control has the appid bound to that appid field.

    It's not nice, it's a workaround, but it works.

  • Gerard Verbruggen Profile Picture
    175 on at
    Hi All,
     
    I stumbled into the same thing and ended up solving it like this:
     
    Added a simple table where I store the APP id's per environment:
     
     
    And created a eventhandler to set the correct AppId for the current environment:
     
        [FormDataSourceEventHandler(formDataSourceStr(LedgerJournalTransVendInvoice, LedgerJournalTrans), FormDataSourceEventType::Activated)]
        public static void LedgerJournalTrans_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
        {
            FormRun formRun = sender.formRun();
            PowerAppsHost powerAppsHost = formRun.design(0).controlName("PowerAppsHost"); //Get the PowerApp control
            PowerAppsIds powerAppsIds; //Table holding the PowerAppID
    
            select firstonly powerAppsIds
                where powerAppsIds.Environment == XXX_General::checkEnvironment() 
                && powerAppsIds.AppName == @"Attachment";
           
            powerAppsHost.AppId(powerAppsIds.AppId);
        }
     
    That XXX_General::checkEnvironment():
     
        static XXX_Environments checkEnvironment()
        {
            var env = Microsoft.Dynamics.ApplicationPlatform.Environment.EnvironmentFactory::GetApplicationEnvironment();
            XXX_Environments ret; //Enum holding Prod, UAT2, UAT1 and Other
    
            switch(env.Infrastructure.FullyQualifiedDomainName)
            {
                case "prodURL.operations.dynamics.com":
                    ret = XXX_Environments::Production;
                    break;
                case "UATURL.sandbox.operations.dynamics.com":
                    ret = XXX_Environments::UAT1;
                    break;
                case "PreProdURL.sandbox.operations.dynamics.com":
                    ret = XXX_Environments::UAT2;
                    break;
                default:
                    ret = XXX_Environments::Other;
                    break;
            }
    
            return ret;
        }
    Maybe this helps someone.
     
    Cheers,
    Gerard
     

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 192 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 129

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans