Showing a custom entity in an IFRAME

I have had cause to enforce a 1:1 relationship between my main entity (modification of the Contact entity) and a custom one. There are several ways that this can happen but I decided the way I was going to do this was to remove the user's ability to create the object and use a plugin instead.

On creation of the Contact entity a single custom entity instance is created, it's object ID from creation is then written back into a field on the Contact entity. I then use an IFRAME to display the entity itself (bypassing the related entity list) thus:

iFinance.src = "../../userdefined/edit.aspx?id={90450BF2-BF0C-DF11-9A07-0003FF5808D8}&etc=10011#";


The ID value will be taken from the field in production but for development purposes I have hard coded a single record in the form at the moment.

You can use this to show any custom entity, to double check just navigate to the entity you want and then check the IIS logs for the request made.

But once you have that address you see a form inside a form and that is not ideal, especially for screen layout and space. So you need to make a few alterations as well. I found this code out there but have lost the citation (anyone recognise it then drop me a line and I will add the link):


iFinance.attachEvent( "onreadystatechange" , financeReady);

function financeReady()
{
var iDoc = iFinance.contentWindow.document;
if(iDoc.getElementById("crmMenuBar") != null)// && iDoc.getElementById("btnBack") != null)
{
iDoc.getElementById("crmMenuBar").removeNode(true); // hide the top menu bar
iDoc.getElementById("leftNavBreadcrumbText").removeNode(true);
iDoc.getElementById("leftNavBreadcrumbImg").removeNode(true);
iDoc.getElementById("tdRelatedInformationPane").removeNode(true);


var imgs = iDoc.getElementsByTagName('img');
for (var i=0;i[less than]imgs.length;i++) {
var html = imgs[i].outerHTML;
if (html.indexOf('LargeEntityIcon')!=-1) {
imgs[i].parentNode.innerHTML=""; //Delete the large icon on the top left
}
}


This results in almost all the screen apart from the tabs being removed and the tabs expand left to fill out the space. Unfortunately I have yet to figure out how to get rid of the space to the top of that screen (where the large icon lives) so the form looks a little squashed on the page.

Of course you also have to remove the node on the left navigation pane of the contact record so that the user cannot navigate to the entity relation list on their own.

0 Responses to “Showing a custom entity in an IFRAME”: