The 1:N relationship needs these parameters in the request URL: oId, oType, security, tabSet
The N:N relationship needs an extra parameter: roleOrd in the request URL, which has been involved in the code.
var navId = "nav_new_new_myentity_account";
if(document.getElementById(navId) != null)
{
var tmp = document.getElementById(navId).onclick.toString();
tmp = tmp.substring(tmp.indexOf("'")+1, tmp.indexOf(";"));
var loadArea = tmp.substring(0, tmp.indexOf("'"));
var roleOrd = (tmp.indexOf("roleOrd") == -1) ? -1 : tmp.substring( tmp.indexOf("roleOrd"), tmp.lastIndexOf("'")).replace("\\x3d", "=");
crmForm.all.IFRAME_view.src = (roleOrd == -1) ? GetFrameSrc(loadArea) : GetFrameSrc(loadArea) + "&" + roleOrd;
}
function GetFrameSrc(tabSet)
{
if (crmForm.ObjectId != null)
{
var id = crmForm.ObjectId;
var type = crmForm.ObjectTypeCode;
var security = crmFormSubmit.crmFormSubmitSecurity.value;
var path = document.location.pathname.substring(0, document.location.pathname.indexOf("edit.aspx")) + "areas.aspx?";
return (path + "oId=" + id + "&oType=" + type + "&security=" + security + "&tabSet=" + tabSet);
}
else
{
return "about:blank";
}
}
Enjoy it! ;-)
25 comments:
Hi Jim
Good post - just wondered is there a way to remove the white border that surrounds the view, to make the form look a bit more seamless. Or resize the view to fill the entire IFRAME?
Thanks SB
Hi SB,
After much trial and error I have managed to remove the white border from my associated view. I added the following code to the onLoad() function. Obviously replace 'training_package_notes' with your iFrame name:
//Remove the white border from the iFrame
var frameName = 'IFRAME_training_package_notes';
var objFrame = document.getElementById(frameName);
objFrame.allowTransparency=true;
Hi Leigh
Thanks for your help. I managed to hack and slash a solution for my immediate needs using the following code.
//Hide borders of IFRAMES
var frameName = 'IFRAME_XXX';
var objFrame = document.getElementById(frameName);
var objWindow = document.frames[frameName];
objFrame.allowTransparency=true;
objFrame.onreadystatechange = function ()
{
if (objWindow.document.readyState=='complete')
{
objWindow.document.body.style.backgroundColor='transparent';
if (objWindow.document.getElementsByTagName('BODY')[0]!=null)
{
objWindow.document.getElementsByTagName('BODY')[0].style.padding='0px';
}
if (objWindow.document.getElementsByTagName('TABLE')[0]!=null)
{
objWindow.document.getElementsByTagName('TABLE')[0].cellPadding='0';
objWindow.document.getElementsByTagName('TABLE')[0].style.border='0px';
}
}
}
Thanks SB
Why do you need the additional onreadystatechange stuff?
Hi Leigh
Credit here goes to:
http://crm.atechnisch.nl/2008/01/related-entity-in-iframe/
I'm not sure what the code is doing in its entirety.
Cheers
To Stringer: nice to know it works for you! ;-)
To Leigh and Inderpal: Without using onreadystatechange event, you won't know when the document has been loaded in the iframe, so it's not possible to control the element inside the iframe.
Onclick event is causing an error. What am I supposed to be entering for what the navId equals?
all i changed was navId
Iframe_name.src, id and type
Hi Jim,
I used your coding. But i cannot get the result. the IF loop cannot be executed. What can i do now?
Thanks and Regards,
Venkatesh.S
You maked clear points about online business ideas through your blog and it is very useful to make money from online at home in part time jobs Thanks.
How to create Blog
How to Make Money Online
Affiliate Programs
喝花酒
酒店喝酒
暑假打工
寒假打工
酒店小姐
酒店兼職
禮服店
酒店經紀
酒店兼差
酒店
酒店經紀人
酒店現領
酒店經紀爆米花
酒店經紀
酒店打工
酒店上班
假日打工
台北酒店經紀
酒店pt
酒店pt
酒店應酬
粉味
酒店經紀PRETTY GIRL
酒店經濟
酒店經濟
晚上兼差
Thanks for posting this. My apologies but I am not understanding one thing about the code. Where in your sample do you point to the specific iframe? I'm assuming that somewhere in your code I need to rename the iframe.
Thanks!
Jim,
Can you please tell me how to get the id from the selected row in the grid that is displayed in an Iframe? 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];
}
That gets me the selected item, but I need the guid id of the entity to pass to reporting services
thanks
Hi Jim,
what if i wanna show the associated view of N:1 relationship? is it possible to do it?
Thanks,
DD
Adi, I am having issues with this working, here is what I have? Am I setting the field correctly.
How do I use this for multiple related entities?
var navId = "nav_new_contact_priorityissues";
if(document.getElementById(navId) != null)
{
var tmp = document.getElementById(navId).onclick.toString();
tmp = tmp.substring(tmp.indexOf("'")+1, tmp.indexOf(";"));
var loadArea = tmp.substring(0, tmp.indexOf("'"));
var roleOrd = (tmp.indexOf("roleOrd") == -1) ? -1 : tmp.substring( tmp.indexOf("roleOrd"), tmp.lastIndexOf("'")).replace("\\x3d", "=");
crmForm.all.IFRAME_priorityissues.src = (roleOrd == -1) ? GetFrameSrc(loadArea) : GetFrameSrc(loadArea) + "&" + roleOrd;
}
function GetFrameSrc(tabSet)
{
if (crmForm.ObjectId != null)
{
var id = crmForm.ObjectId;
var type = crmForm.ObjectTypeCode;
var security = crmFormSubmit.crmFormSubmitSecurity.value;
var path = document.location.pathname.substring(0, document.location.pathname.indexOf("edit.aspx")) + "areas.aspx?";
return (path + "oId=" + id + "&oType=" + type + "&security=" + security + "&tabSet=" + tabSet);
}
else
{
return "about:blank";
}
}
Hi Jim,
First off, Great posts! I used your code for the Associated views in an Iframe with great success! (until recently)
Everything was working great for about 99% of our users until about 3 weeks ago. Now every page that has this code running on it, freezes IE for about 20-30 seconds between clicks (sometimes more). The CPU spikes to about 50% while its frozen, nothing shows in a fiddler trace... really odd. Any thoughts? I've tried turning everything I can think of off, with no luck. Will have to look for another alternative if I can't get this corrected soon.
Any assistance would be greatly appreciated! Thanks!
Keith
Hi Jim,
Thank's for the code it works great. However, when I access the parent record using IFD, the iFrame has an error: "Navigation to the webpage was cancelled." Do you know what may be going on?
Hello,
What would be the link (IE Developer Toolbar) identification of the link?
este código é um javascript, você adiciona ele como um recurso web?
thanks
I beleive we are missing "}".
Hi Jim,
I have created a custom entity called 'Stakeholder' which is related to company. I want to show the associated view of stakeholder in a tab on the company form.
I have looked at countless websites but it doesnt see to work, is there a problem with the code I have? or is it not possible with custom entities?
This is the code that doesnt appear to work:
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_Stakeholder.src = GetFrameSource("areaStakeholder");
If i were to use you code, and do not have the developer toolbar, how else could i find associated link, is that the ID line at the very top?
Keep up the fantastic piece of work, I read few blog posts on this web site and I believe that your site is real interesting and has lots of great information. ERP Software in Mumbai || System Software || CRM Software in Mumbai || MLM Software
I really appreciate spending some time to talk about that, I believe firmly regarding this and so really enjoy understanding more about this kind of subject.This is also a very good post which I really enjoyed reading. It is not everyday that I have the possibility to see something like this. CRM Software || MLM Software in Mumbai || ERP Software || System Software in Mumbai
học kế toán thực hành cấp tốc
học kế toán thực hành cấp tốc
học kế toán thực hành tại cầu giấy
học kế toán thực hành tại thanh xuân
]học kế toán thực hành tại hà đông
học kế toán thực hành tại long biên
học kế toán thực hành tại long biên
học kế toán thực hành tại hải phòng
học kế toán thực hành tại bắc ninh
học kế toán thực hành tại tphcm
học kế toán thực hành tại quận 3
học kế toán thực hành tại hải phòng
học kế toán thực hành tại bắc ninh
học kế toán thực hành tại bình dương
học kế toán thực hành tại biên hòa
học kế toán thực hành tại vinh
học kế toán thực hành tại vinh
học kế toán thực hành tại huế
học kế toán thực hành tại đà nẵng
học kế toán thực hành tại đà nẵng
học kế toán thực hành tại đà nẵng
học kế toán thực hành tại hải dương
học kế toán thực hành tại hưng yên
học chứng chỉ kế toán
học kế toán ở đâu tốt
Post a Comment