An embedded grid is a great way to see associated records without having to navigate to the associated view. There are some drawbacks to the embedded grid such as possible speed issues and limitations of the grid itself but these are often outweighed by the advantages – especially if the items in the grid are primarily only viewed by the user.
One method of embedding a grid on a form is through the use of an iframe. This is outlined very well by Michael Hoehne on his Stunnware site, http://www.stunnware.com/crm2/topic.aspx?id=JS27
Following are a recap of the steps from that site along with an addition for placing a custom entity's associated view in the embedded grid:
1a. (Standard Entities) Obtain the tabset name of the associated view you want to include on the form. Standard entities' tabset name can be found by:
- Open the main form and click the associated entity in the navigation pane.
Paste/Type into your web browser address bar:
javascript:alert(document.frames[1].location)
This should open a window with a url with the tabset name. Copy that url for use later
1b. (Custom Entities) The tabset name of the associated view for custom entities is the relationship name of the associated entity. This name is created (or specified by the user) when the relationship is created between two entities. This can be found by:
- Open the main entity in customization
- Open the 1:N Relationships area (CRM 4.0) and find the related entity
- Open that relationship and the Name field (second from the top) is what you'll use in the javascript below
- Place an iframe on the parent record form and make note of the name you give the iframe. The display properties (size) of the iframe might need to be edited depending on the grid.
Add the following javascript to the OnLoad of the form:
function GetFrameSource(tabSet) {
if (crmForm.ObjectId != null) {
var oId = crmForm.ObjectId;
var oType = crmForm.ObjectTypeCode;
var security = crmFormSubmit.crmFormSubmitSecurity.value;
return "areas.aspx?oId=" + oId + "&oType=" + oType + "&security=" + security + "&tabSet=" + tabSet;
}
else {
return "about:blank";
}
}
crmForm.all.IFRAME_salesprofile.src = GetFrameSource("new_account_salesprofile");
- The last line of the above code will be where you make the changes. The IFRAME_Invoices will be replaced with the name of your iframe (from step 2). The .src needs to be added to your iframe name. The new_account_salesprofile will be replaced with the tabset name from step 1a or 1b.
If all goes well your form will look something like:
How do you hide the menu items?
Posted by: Brad | June 11, 2008 at 11:13 AM
Fantastic post! One of my clients beat me to the punch and implemented this very piece of code last week. Keep up the good work.
Posted by: Michael Dodd | July 23, 2008 at 11:22 PM
Thanks for the post. Really useful.
I know this may sound picky, but is there a way to change the background of the grid from with the the Dynamics CRM blue? I can't figure out how this could be set.
Posted by: Emanuel Caraza | August 19, 2008 at 12:01 PM
Is it possible to display the results of an Advanced Find Saved View in an iFrame also?
Posted by: Hann | December 01, 2008 at 06:58 PM
just great code works awesome thanks mate! cheers!
Posted by: travel agent | February 16, 2009 at 07:31 AM
This is fantastic. So easy to implement as well!!
Posted by: James | April 13, 2009 at 12:46 PM
Can you please tell me how to get the id from the selected row in the grid that is displayed in an Iframe? I need to pass the ids from the selected rows to reporting services.
I got this far:
var frameDoc = document.getElementById("IFRAME_Saw").contentWindow.document;
var a = frameDoc.all['crmGrid'].InnerGrid.SelectedRecords;
var selectedItems = new Array(a.length);
for (var i=0; i < a.length; i++)
{
selectedItems[i] = a[i][0];
}
This gets me the guid of the associated view. I need the entity id.
That gets me the selected item, but I need the guid id of the entity to pass to reporting services
thanks
Posted by: jodi.cannon@mhctruck.com | September 24, 2009 at 03:16 PM
Not sure how to get the guid of a selected row. Perhaps another reader can chime in.
Sorry I can't offer more.
From: typepad@sixapart.com [mailto:typepad@sixapart.com]
Sent: Thursday, September 24, 2009 3:17 PM
To: Matt Putnam
Subject: [Customer Effective Blog] jodi.cannon@mhctruck.com submitted a comment to 'Embedded Grid on CRM form - including custom entities'.
[cid:image001.png@01CA3DC0.80B9DD00]
[cid:image004.png@01CA3DC0.80B9DD00]
NEW! More options for replying to comments via email:
* To reply privately to the commenter, click on the commenter's email address below.
* To reply publicly on your blog, reply to this email.
Posted by: Matt Putnam | September 25, 2009 at 09:14 AM
PDAs, white and brown goods etc. This aggregation results to a significant amount of processing power and can be used productively for two main purposes: Firstly, in the local level, this additive power may enhance the application and ambient intelligence services that this heterogeneous computing environment provides to the final user. Secondly, in a larger scale, this computer aggregation can offer its redundant processing power to the Global Grid
Posted by: generic Viagra | March 12, 2010 at 11:28 AM
should I open a window with a url with the tabset name?
Posted by: Vimax | May 04, 2010 at 11:38 AM
Fantastic post! One of my clients beat me to the punch and implemented this very piece of code last week. Keep up the good work.
Posted by: NFL Jerseys | July 19, 2010 at 07:37 AM