JavaScript – Refresh Forms

Here is a quick JavaScript code example. Having added a new opportunity on a contact I wanted to refresh the contact form and at the same time save any changes.

This concept might be useful in several circumstances, say you have a customization on the opportunity that updates fields on the contact. Then refreshing the contact page would allow those alterations to show.

When I am using USD I intend to experiment with using the Xrm.Page.data.refresh(save) command in RunXrmCommand actions. As I have several situations when I want to refresh the parent following creation of a child.

Hopefully you might find this useful.

function OnLoad() {
  setTimeout("Refresh();", 2500);
}

function Refresh() {
  Xrm.Page.getControl("contactopportunitiesgrid").addOnLoad(GridOnloadFunction);
}

function GridOnloadFunction() {
  var save = true;
  Xrm.Page.data.refresh(save);
};

Happy coding. J

2 thoughts on “JavaScript – Refresh Forms

  1. Pingback: USD – The Book | Microsoft Dynamics CRM and Unified Service Desk

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s