Load and refresh any associated view in MS CRM
Normally when you display an associated view inside an IFRAME some of MS functionality breaks e.g. the automatic refresh when you add a new record. Adi Katz has developed the N2NViewer and AssocViewer to display resp. a many-to-many or a one-to-many grid inside MS CRM. The latter apparently does not refresh activities or history because a separate MS function needed to be called.
In the function below I have combined both viewers into one and added an extra check to call the correct function to refresh activities and history as well.
Copy the following code in the form OnLoad event: Read more
Refresh associated view grid in iFrame
This function can be used to programmatically refresh a grid of an associated view displayed in an iFrame without having to reload the entire form or press F5.
In this example we refresh only the grid when clicking on the tab in which the associated view resides.
Read more
Override a button of any Associated View
This post describes how you can override the function of any button (e.g. New Quote) of the associated view displayed in either the navigation pane (example 1) or in an iFrame (example 2. The function requires the following parameters:
| area | : name of the iFrame or area (when displayed in the NavPane e.g. areaQuotes) |
| button | : name of the button to override (use IE Developer Toolbar to get the ID of the button) |
| newfunction | : new function to call |
Copy the code in the Onload event and call the function using one of the examples below:
Change the default filter of an Associated View
This article explains how to set a default filter on any associated view, displayed both in the navigation pane (example 1) or in an iFrame (example 2). This function requires the following parameters:
| area | : name of the iFrame or area (when loaded in NavPane e.g. areaContracts) |
| field | : name of the filter field e.g. statecode or actualend |
| defaultValue | : default value or text (e.g. 'All') |
Statuses per entity
The following table gives an overview of the statuses per entity:
| Contract ('statecode') |
Cases ('statecode') |
Activities ('scheduledend') |
History ('actualend') |
| 0=Draft 2=Active 3=On Hold 4=Cancelled 5=Expired 'All'=All |
0=Active 2=Cancelled 'All'=All |
'Overdue'=Overdue 'Tomorrow'=Tomorrow 'NextXDays;7'=Next 7 days 'NextXDays;30'=Next 30 days 'NextXDays;90'=Next 90 days 'NextXMonths;6'=Next 6 months 'NextXMonths;6'=Next 6 months 'All'=All |
'Today'=Today 'LastXDays;7'=Last 7 days 'LastXDays;30'=Last 7 days 'LastXDays;90'=Last 7 days 'LastXMonths;6'=Last 6 months 'LastXMonths;12'=Last 12 months 'All'=All |
| Opportunities ('statecode') |
Quotes ('statecode') |
Orders ('statecode') |
Invoices ('statecode') |
| 0=Open 1=Won 2=Lost 'All'=All |
0=Draft 1=Active 2=Won 3=Closed 'All'=All |
0=Active 1=Submitted 2=Cancelled 3=Fulfilled 4=Invoiced 'All'=All |
0=Active 1=Closed 2=Paid 3=Cancelled 'All'=All |
Copy the code in the Onload event and call the function using the examples below:
Remove 'Add Existing xxxxx to this record' button
Sometimes you want to hide the 'Add Existing xxxxx to this record' button in MS CRM. Thanks to Dave Hawkes and other CRM guru’s there is a way.
Follow this link to see the original post by Dave Hawkes: http://blog.davehawes.com/post/2008/04/24/MSCRM-4-Remove-Add-Existing-xxxxx-button.aspx
After testing this script I found that it was not entirely working for Associated Views in an iFrame. In addition, the buttons kept reappearing when the form was resized.
I modified the code so that it works for Associated Views displayed both in the NavPane as well as in a iFrame.
Tip:
When multiple languages are used in your implementation you can pass the title of all appropriate languages in the title Array before calling the function e.g. var hideButtons = ["Add existing Interest to this record", "Een bestaande Interesse toevoegen aan deze record"];
Please note:
This script calls 1 additional function also posted on our blog: gLeft().
Copy the function below in the OnLoad event:
Dynamically load any entity in an iFrame
There are a lot of examples on how to load associated entities in an iFrame in MS CRM. These all have in common that the entity in the associated view is directly related to the active entity, namely the entity displayed in the form.
In this article I will explain how you can load any entity in an iFrame, regardless of the entity that is showing by passing the correct GUID.
Scenario:
In this example I want to show the active contracts of the selected customer directly on the Case form. When the user changes the customer, the appropriate (active) contracts are displayed.
Step-by-Step:
First we need to determine the exact URL of the entity we want to display.
- Open a record of the entity in question and press F11.
- Look for the part between "…/sfa/" and "/areas.aspx?id=…” For example: accts = accounts and conts = contacts.
Next we need to determine the area which we need to load. For system entities this always starts with “area”. For custom entities it is the name of the 1-N relationship. In this example we want to load contracts, thus the area we need to call is areaContracts.
Finally, we need to retrieve the correct GUID of the customer lookup. See this post on how to retrieve a value from a lookup: gLookupGetValue().
Here’s the complete code, including additional instructions: Read more
Dynamically load an associated entity in an iFrame
Always wondered how to load an associated entity in an iFrame in MS CRM? Here's how:
- Add an iFrame to the form
- URL = about:blank
- Activate the "Pass record…. " option.
- Deactivate all other options.
Copy the following code in the form OnLoad event: Read more

