RE: How to make the Canvas App id constant across environments?
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.