Lately, I been working with Embedded Canvas-apps a lot. I have a few tips for you that would come in handy while planning the utilization of these apps in your project.
My List –
1. Model-app object does not load instantly when Canvas-app is loaded. It might take anywhere from 1 to 5 seconds for the @ModelDrivenFormIntegration to load with CDS values.
Solution – Add a Timer control to the Canvas-app and load the values from @ModelDrivenFormIntegration object on 3 sec TimerEnd() function. The model app object should load with values from the parent record by the end of the timer. See #4 below on how to load @ModelDrivenFormIntegration object so all lookup values are loaded.
2. When you patch values in Canvas-app for the model-app record, to use the new patched values in Canvas-app, you would require to re-run the timer and re-load ModelDrivenFormIntegration object.
Solution – Stop, Reset and start the timer again if you are displaying values of, for example, Lookup Columns, etc. See #5 below.
3. An Embedded App only runs in Edit Forms and not in New forms.
Solution – Pre-save the form using javascript to load your Embedded Canvas-app.
4. You might see empty values for lookup fields from the @ModelDrivenFormIntegration model-app’s object.
Solution – In order to access Lookup fields or Related items, you need to pre-load the Model-app parent record of the Canvas-app in reference by the unique id of the model-app item before using it in the query. Example below.
UpdateContext( { _modelappRecord: LookUp( 'PrimaryEntity', 'PrimaryEntity UniqueId Colum' = ([@ModelDrivenFormIntegration].Item.'Unique ID') ) } ); UpdateContext({_lookupEntityRecord: _modelappRecord.'Entity Lookup Column'});
‘Entity Lookup Column’ is the Lookup column in model-app to a different entity. _lookupEntityRecord will contain a record of the lookup item. You can further access properties of the lookup entity by using its properties example : _lookupEntityRecord.ID
Alternatively, it is suggested to add a hidden grid-bind to the primary entity so ModelDrivenFormIntegration keeps in sync. I found the above timer and pre-load of _modelappRecord more convenient as the grid was making the canvas-app slower.
5. Sometimes the @ModelDrivenFormIntegration does not load and the timer also runs out.
Solution – Recommended adding a reload button\icon and re-trigger the timer on the reload button. Something like below. Set _startTimer to StartTimer function of your Timer. Example below.
UpdateContext({ _startTimer: false });
Reset(Timer);
UpdateContext({_startTimer: true});
6. Canvas-app refreshes if any one required value is set on the Model-app.
7. When patching values from within the Embedded app in your model-app, make sure to refresh the form to reflect the changes. Example below.
Patch( 'PrimaryEntity', _modelappRecord, { IsComplete: 'IsComplete (PrimaryEntity)'.Yes } ); ModelDrivenFormIntegration.RefreshForm(true);
7. The same Canvas-app can be added to different screens\sections of your Model-app by duplicating the app’s Canvas-app Id. Bind the other embedded apps to static value and then add the existing app’s id.
8. There is a limit of three Web Canvas-Apps per form where only one app loads at a time. If you try to add another copy of an embedded canvas-app, you will see the following error.
9. Canvas-app does not inherit Security Roles from Model-app form. You have to explicitly share your Canvas-app with users and provide them with a security role (several exceptions to it, read below).
Sharing an Embedded Canvas-app With Users
- Regardless of permissions, no two people can edit an app at the same time. If one person opens the app for editing, other people can run it but not edit it.
- You can’t share an app with a distribution group in your organization or with a group outside your organization.
- You can share an app with Office 365 groups. However, the group must be security enabled.
- You can assign security roles to individual users and security groups (including mail-enabled security groups) while sharing the Canvas-app with them.
- If your AD security group is mapped with the dynamics’ AAD security group Team and has a security role assigned to it, you do not need to assign the role again to that security group while sharing the Canvas-app. Simply share the Canvas-app with the security group or AAD group with no security roles assigned as they inherit the roles from the mapped group Team.
Also, read Microsoft’s guidelines on using Embedded Canvas-app @ Guidelines on working with embedded canvas apps. Very useful.
Related: Clear Date Field in CDS for a Model-driven Power App using business process
Please send an email for new posts.