{Dynamics CRM/ 365 + Quick View Forms} Refresh Quick View form control programmatically using new Client side API for Quick View forms in Dynamics 365

Recently I came across a requirement where the customer needed to refresh the quick view form on an entity on change of the related field programmatically. So let me explain the requirement here.

  • Let’s say we have custom entity – “Quick View Test”.
  • Quick View Test has a  N:1 relationship with contact.
  • Quick view form of the contact is designed as shown in the screen shot below. It has the following stuffs
    • First Name
    • Last Name
    • Email
    • A sub-grid showing Related emails


  • The form for the Quick View Test Entity is designed as follow


So far so good. The requirement here is when the user changes the contact lookup on the entity form, the quick view form should refresh and reflect not only the new contact’s first name and last name, but should refresh the associated emails grid as well to show the emails associated to the contact.

Wondering what’s there to worry about? Doesn’t changing the contact lookup automatically trigger refresh of all the controls on the forms?

Well, unfortunately it does not.

I have a contact called Andrew Book with two associated emails.


However when I change the contact lookup on the form, the grid in the quick view form does not refresh.


The user have to explicitly refresh the grid to view the associated emails.

Well this can be done with a simple script with the help of new Client API’s for Quick View Forms.

// JavaScript source code

function QuickViewFormTest() {
    var quickViewControl = Xrm.Page.ui.quickForms.get("related_contact");

    if (quickViewControl != null) {
        setTimeout(function () {
        }, 500);

Register this function on change of contact and you would see the grid refreshing.

You might be thinking, why there is a timeout of 500 milliseconds. The reason is when you change the contact lookup OOB it fires a refresh of the quick view form which unfortunately does not refresh. Our custom code fires another re-fresh just after that which loads the grid.

If you want to access the individual controls on the Quick View form, you would even do that using the below code.

var emailsGrid = quickViewControl.getControl(“grid_emails”) // grid_emails is the control name


The above code access the grid in the quick view control and refreshes the same.

Hope this helps!


-Debajit Dutta

(Visit our products page at www.xrmforyou.com)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s