CRM Blog

Adding An IFrame That Contains A View Of Related Entity

by Danny Varghese 03.18.08
Situation

CRM has out of the box capabilities to add IFrames to entity forms.  These IFrames can allow a user to access any webpage inside of a system or custom CRM form.  The beauty of CRM comes to light here, with the fact that CRM forms are html web based pages, each with its own url.  Developers can take that url, and pass it into the IFRAME, to open up other entities, forms, or even associated views!  This comes in handy when clients don’t want to navigate away from the main screen to see information on related entities.

Example Of Use

For example, say on the Account form, you wanted to see an IFrame that contains an associated view of all activities belonging to that account.  Here are the steps you can take (again, this can be done with any entity):

1.       Under Settings à Customization à Go to entity form, open the form

2.       Add an IFrame to the tab and section you want, specify the name and set the url to “/_root/blank.aspx”

3.       Using JavaScript, add the code below to point the IFrame’s source to a given url.  In this case, the url of a window that has all activities related to a particular account.

var urlAct = ""; urlAct =  "areas.aspx?oId=" + crmFormSubmit.crmFormSubmitId.value + "&oType=" + crmFormSubmit.crmFormSubmitObjectType.value + "&security=" + crmFormSubmit.crmFormSubmitSecurity.value +"&tabSet=areaActivityHistory"; document.getElementById('IFRAME_History').src =urlAct;

4.       The code snippet above creates a url that points to an existing CRM view that has all activities for a given account.  Then it retrieves IFrame element by name (you specified this in step 3), and sets the source to the newly created url.

The result is on the Account form, wherever you placed the IFrame, it will show the view of all activities related to that account.  Again this IFrame can be created for any entity with a relationship to another entity.

Filed under:

Comments

# Katyc said on April 13, 2008 09:03 PM:

I use this code but i cant create or select anothe view in this iframe.

could you help me pls

# Jason said on May 8, 2008 08:11 PM:

Have you tried this with a N:N relationship? I am struggling to get this to work. any ideas?

# Darryl said on May 9, 2008 02:33 PM:

This worked with first install and saved me hours of tinkering with other jscript approaches.

Thanks,

# Danny Varghese said on May 22, 2008 02:11 PM:

Hi Katyc,

Sorry for the late response, but I've been away for about two months and am just getting back.  Could you please be more specific in your question?  What kind of view?  Thanks!

# Danny Varghese said on May 22, 2008 02:14 PM:

Hi Jason,

Sorry for the late response, but I've been away for about two months and just getting back.  To answer your question, you have to add a new parameter for N:N relationships.  

When you're creating the url, you'll have to append the following to the string: + "&roleOrd=2";

I'm not sure what the parameter is but it seems to indicate the relationship ordinal, or which side of the relationship you want viewed in the I_Frame.  The parameter name is static, but the value of "2" can be "1" is some cases.  If I find out more, I'll be sure to update this.

Hope this helps, thanks for your patience!

# Rob said on August 15, 2008 10:54 AM:

where does the area* part of the url come from how do i find this out....

above it says -> tabSet=areaActivityHistory

many thanks

# Jordan said on September 4, 2008 09:43 AM:

I think this is what Katyc meant:

She wanted to use a different view other than the standard associated view for an iFrame. (Example: "Advanced Find" view)

-------------------------

Hi Katyc,

Sorry for the late response, but I've been away for about two months and am just getting back.  Could you please be more specific in your question?  What kind of view?  Thanks!

# Danny Varghese said on October 14, 2008 09:24 AM:

Hi Rob,

The way you can find that "area" parameter out is either you can type "ctrl-n"  to open a new IE page and then view the source of the page, or if your IE toolbar allows to view the source directly.  Once you have the page source code visible, search for that parameter and you can just copy and paste!  Good luck!

# Danny Varghese said on October 14, 2008 10:51 AM:

Hi Katyc,

I_Frames reference a URL, so you can simply put the URL for the advanced find.  Now if you want the advanced find to run with specific parameters found on the form you're on, then you can dynamically build the url and set the I_FRAME url as mentioned in this blog.  Hope this helps, good luck!

# Mark said on December 3, 2008 10:53 AM:

I get an error where the IFrame is when creating a new account .  Can you append your code to deal with the null?  Accounts with existing records for my custom entity show up fine in the IFrame

# Danny Varghese said on December 15, 2008 02:50 PM:

Hi Mark,

To get around this, I check the form type when it loads.  So if the form type = 1 (new/create form), then I don't call the code.  This will prevent the error from happening.  Hope that helps!

# Rodrigo said on June 22, 2009 04:52 PM:

when click in the new button, how i can take de objectid of parent window, in the case the iframe ?

Leave a Comment

(required) 
(required) 
(optional)
(required) 
Security Check
Please answer the simple math problem below.

(required)