cancel
Showing results for 
Search instead for 
Did you mean: 
Inogic

Refresh Dynamics 365 CRM Subgrid from Embedded Canvas App

In Microsoft Dynamics 365, the ability to embed Canvas Apps brings the power of Canvas Apps to their model-driven forms.

Recently, we got a requirement to create a record of the related entity (e.g., “Suggestion”) from the Canvas App embedded in the Appointment entity form. There was a subgrid of the “Suggestion” entity added next to the Canvas App on the Appointment form. After creating the suggestion entity record, we should see the newly added suggestion record in the subgrid, i.e., the subgrid should be refreshed.

 

At first, we tried the below steps to achieve this requirement.

 

Step 1: Create the required Canvas App with a simple form to create the suggestion record

Refresh-Dynamics-365-CRM-Subgrid-from-Embedded-Canvas-App-1-1536x666

 

Step 2: Add the related records subgrid and embedded Canvas App to the model-driven form.

Add the related records subgrid and embedded Canvas App to the model-driven app.

Refresh-Dynamics-365-CRM-Subgrid-from-Embedded-Canvas-App-2-1536x664

 

Step 3: Check by filling out the Canvas Apps form on Appointment and submit it.

Now fill out the form and submit it on Appointment.

Refresh-Dynamics-365-CRM-Subgrid-from-Embedded-Canvas-App-3-1536x663

 

It does not refresh the subgrid after the embedded Canvas App submits, as shown below.

Refresh-Dynamics-365-CRM-Subgrid-from-Embedded-Canvas-App-4-1536x620

 

Step 4: Add the below formula to the button control (OnSelect)

Add the below formula to the OnSelect property of the button after the SubmitForm method.

ModelDrivenFormIntegration.RefreshForm(true);
 

Refresh-Dynamics-365-CRM-Subgrid-from-Embedded-Canvas-App-5-1536x666

 

After adding the above expression to the OnSelect property of the button, it will automatically refresh the subgrid after the embedded Canvas App submits, as shown below.

  1. Subgrid before clicking on Add suggestion.
     

    Refresh-Dynamics-365-CRM-Subgrid-from-Embedded-Canvas-App-6-1536x607

     

  2. Subgrid refreshes after the add suggestion button click.
     

    Refresh-Dynamics-365-CRM-Subgrid-from-Embedded-Canvas-App-7-1536x590

     

  3. Subgrid shows the record after it’s refreshed.
     

    Refresh-Dynamics-365-CRM-Subgrid-from-Embedded-Canvas-App-8-1536x594

     

Conclusion:

By following these steps, you can effectively refresh a subgrid within Dynamics 365 upon submission of data from an embedded Canvas App, all within the same tab.