Updated for Version 4...
Sometimes I want to show related entities in iFrames on the forms rather than via the LHS navigator. The technique shown below allows you to do this quickly and easily and allows you to have a number of related entities showing this way on the same page.
For this example I will show a related entity called new_city in an iFrame called Cities. In the IFrame properties it is important that restricting scripting is UNticked and that the ID is passed. The IFrame is therefore referenced as crmForm.all.IFRAME_Cities (ignore the old entiy names in the pics below).
I set the contents of the IFrame in the onLoad event using the following line of code and the function shown below
The function that I use to set the contents of the IFrame is included as part of the onLoad for the page (make sure it is loaded before the line above is called)
//----------------------------------------------------------------------------------------------
function getFrameSource( tabSet ) {
//----------------------------------------------------------------------------------------------
if (crmForm.ObjectId != null) {
var oId = crmForm.ObjectId;
var oType = crmForm.ObjectTypeCode;
var security = crmFormSubmit.crmFormSubmitSecurity.value;
//this two lines are optional and used to hide th link on the LHS navigation
var navItem = window.document.getElementById( 'nav_'+ tabSet );
navItem.style.display = 'none';
return "areas.aspx?oId=" + oId + "&oType=" + oType + "&security=" + security + "&tabSet=" + tabSet;
} else {
return "about:blank";
}
};
//Line to in set IFrame contents
crmForm.all.IFRAME_Cities.src = getFrameSource('new_new_state_new_city');
14 comments:
hi,
I've still a problem with displaying custom enity (new_prognozowanie) within Opportunity form in IFRAME.I did following you but it dosen't work.
I created an IFRAME_Prognoza in Opportunity form and placed there your piece of code (onload event) like this:
if (crmForm.ObjectId != null) {
var oId = crmForm.ObjectId;
var oType = crmForm.ObjectTypeCode;
var security = crmFormSubmit.crmFormSubmitSecurity.value;
var navItem = window.document.getElementById( 'nav_'+ tabSet );
navItem.style.display = 'none';
return "areas.aspx?oId=" + oId + "&oType=" + oType + "&security=" + security + "&tabSet=" + tabSet;
crmForm.all.IFRAME_Prognoza.src = getFrameSource('new_prognozowanie');
} else {
return "about:blank";
}
};
and nothing happended. Generally I've a problem with getting a value of tabset
Hi,
there appear to be two issues here:
1.) the function code at the top is has been removed. If you are including this in the onload event you should define the function in the form:
//------------------------------
getFrameSource = function( headingText ) {
//------------------------------
[code as publishe previusly]
};
Make sure to include the ";" at the end of the function braces.
The second issue is in teh calling of the function.
In your situation I think it will look something like this:
crmForm.all.IFRAME_Prognoza.src = getFrameSource('[CURRENT ENTITYNAME_new_prognozowanie');
Note the CURRENT ENTITYNAME will be the schema name of the entity the IFRame is vbeing placed into.
Please et me know if this resolves the issue and vote back on the Forum,
Thanks
Rob
Hi,
About the code displayed above and issues - I corected my code as you mentioned but this still dosen't work.
I added function -getFrameSource and schema name of entity the IFRAME is being placed into -(opportunity). Below I'm showing this code
//-------------------------
function getFrameSource( tabSet ) {
//------------------------
if (crmForm.ObjectId != null) {
var oId = crmForm.ObjectId;
var oType = crmForm.ObjectTypeCode;
var security = crmFormSubmit.crmFormSubmitSecurity.value;
var navItem = window.document.getElementById( 'nav_'+ tabSet );
navItem.style.display = 'none';
return "areas.aspx?oId=" + oId + "&oType=" + oType + "&security=" + security + "&tabSet=" + tabSet;
crmForm.all.IFRAME_Prognoza.src = getFrameSource('opportunity_new_prognozowanie');
};
else
{
return "about:blank";
};
};
Regards
Lidia
Hi,
there a still a few small probs.
The function code that needs to be placed at the top of the form onload event is as follows:
//---------------------------
getFrameSource = function( tabSet ) {
//---------------------------
if (crmForm.ObjectId != null) {
var oId = crmForm.ObjectId;
var oType = crmForm.ObjectTypeCode;
var security = crmFormSubmit.crmFormSubmitSecurity.value;
var navItem = window.document.getElementById( 'nav_'+ tabSet );
navItem.style.display = 'none';
return "areas.aspx?oId=" + oId + "&oType=" + oType + "&security=" + security + "&tabSet=" + tabSet;
} else {
return "about:blank";
};
Underneath this you will need the line of code which calls this function.
crmForm.all.IFRAME_Prognoza.src = getFrameSource('opportunity_new_prognozowanie');
At the moment the line is within the function and so nothing ever gets called / happens.
Hope this helps
Rob
Hi Rob,
Thanks a lot for help but this hasn't worked yet and I realy don't know where the problem is. None java script error only within IFRAME IE issue - Action canceled.
Regards
Lidia
Hi Lidia,
I have emailed you some doco with screen shotes etc in it. Please let me know if this resolves the issue or not.
Regard
Rob
Hi,
I have a need to display a custom entity within an iFrame for a custom entity. Although I'm not a developer, I am experienced with iFrames. I've been through every line of your code but it still doesn't work in my environment. If you could email me your screen shots I would greatly appreciate it.
ladler AT alticoadvisors Dot Com
Thank you very much
I have emailed you some screen shots and the code. Please let me know if this helps.
Regards
Rob
Hello,
I still have an issue to get this working.
I build an IFRAME into Entity new_haspbeveiliging and will show an related entity phonecall.
When i open the Entity i get still an error:
---------------------------
Windows Internet Explorer
---------------------------
There was an error with this field's customized event.
Field: crmForm
Event: onload
Error: Object required
This is the code i use for onload:
//----------------------------------------------------------------------------------------------
function getFrameSource( tabSet ) {
//----------------------------------------------------------------------------------------------
if (crmForm.ObjectId != null)
{
var oId = crmForm.ObjectId;
alert(crmForm.ObjectId);
var oType = crmForm.ObjectTypeCode;
alert(crmForm.ObjectTypeCode);
var security = crmFormSubmit.crmFormSubmitSecurity.value;
alert(crmFormSubmit.crmFormSubmitSecurity.value);
var navItem = window.document.getElementById( 'nav_'+ tabSet );
alert(window.document.getElementById( 'nav_'+ tabSet ));
navItem.style.display = 'none';
return "areas.aspx?oId=" + oId + "&oType=" + oType + "&security=" + security + "&tabSet=" + tabSet;
} else
{
return "about:blank";
}
};
crmForm.all.IFRAME_Operatives.src = getFrameSource('new_haspbeveiliging_phonecall');
Any suggestion whats can be wrong here?
Thanks.
Hi
I am trying to display the products that are related to an Opportunity on
the Opportunity form in an IFRAME. I have created the IFRAME and I have
tested the following bit of Jscript:
// -------------------------------------------------
getFrameSource = function( tabSet ) {
// -------------------------------------------------
if (crmForm.ObjectId !=null)
var oId = crmForm.ObjectId;
var oType = crmForm.ObjectTypeCode;
var security = crmFormSubmit.crmFormSubmitSecurity.value;
var navItem = window.document.getElementById( 'nav_'+ tabSet );
navItem.style.display = 'none';
return "areas.aspx?oId="+ oId + "&oType=" + oType + "&security=" + security
+ "&tabSet=" + tabSet;
}else {
return "about:blank";
}
};
crmForm.all.IFRAME_Products.src = getFrameSource('opportunityproduct');
This bit of Jscript does not seem to be working 100% correctly. When I load
the form I receive an error stating that object could not be loaded. Is there
something wrong with the getFrameSource.
I would really appreciate any assistance.
Thanks very much
Mark
I suspect the problem is with the nameyou are passing to the function
eg: getFrameSource('new_prognozowanie');
To get the name that you need to pass the easiest way is to install the M$ IE Dev toolbar. Then open the entity in a new window with Ctrl-N so that it shows up.
Then use the sector to highlight the current navigation object on the left handside. One of the properties of this will be the name you need.
Hope this helps.
Hi all,
I have a problem when displaying custom entity in IFRAME.
I used to create virtual N:N relationship between my entities new_commune and Contact, and between new_commune and Account by doing this :
document.all.IFRAME_appartenancecommune.src="//areas.aspx?oId=" + crmForm.all.new_codecommuneid.DataValue[0].id +
"&oType=10021&security=852023&roleOrd=2&tabSet=areanew_codezoneappart_commune_commune";
Here I am in Contact Form, oType is the type of my new entity and oId is comming from a lookup inside my form.
But since last week, I have a CRM bug when I click the Save button (this doesn't occur when clicking on Save and Close).
Can anyone help me please !?
Thanks in advance.
Hi Rob - Thanks for the code - been working with it all day, but must be doing something wrong - I have screen shots I'd like you to look at for anything obvious, its there a way to do that?
Thanks, PaulJ
I found this: tried and tested (personally) works 100%, enjoy
Relevant entity form Onload event:
function GetFrameSourceN1(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_YOURIFRAMENAME.src = GetFrameSourceN1('RELATIONSHIPNAME');
Next level: how do you duplicate the script to reference more than one relationship in different iframes on the same form?>
Catch me on http://www.crmtutor.biz or http://twitter.com/CRMtutor
Post a Comment