If you have been using Embedded Canvas Apps and running on load functions, you may run into issues retrieving the context data from your Model Driven app in Dynamics 365. The data from Model Driven Apps has a slight delay in getting to the Canvas App therefore requiring some additional smarts to control.
To work around this I use a timer control to delay any functions by an extra second. This should be plenty of time for the data to transition from the Model Driven App to the Canvas App.
There are a number of reasons you may want to trigger functions on load:
- Calling Flow or a Custom connector with the record GUID
- Aggregating data into a collection from multiple data sources
What will occur is on load of the Canvas App the timer will count down and trigger your functions to retrieve the data, this should be enough time to wait for the data from the Model Driven App.
For the timer control I have the following configuration:
- Timer Auto Start = true
- Duration = 1000 (1 second)
- Visibility = false (Don’t want end users to view)
The OnTimerEnd property is used to store the function that is to be executed when the Canvas App loads. Here I’m using a Flow to take the Account GUID (as this app will be embedded on the Account form). I use the below formula to get the Account record’s GUID First(ModelDrivenFormIntergration.Data).AccountId.
Check out this post about embedded canvas apps: https://the365hero.com/blog/2018/12/24/embedded-canvas-apps-for-dynamics-365/