Display a related entity in context of the parent is old stuff and could be found little every where if you search around. But finding samples to change or modify attached child entities is not so clear. One thing that differs if you render your iframe with a related entity is that it gets loaded during the form onload. This could be used for your advantage to do validation etc (on child/related entities witout callout logic ~ offline enabled = fast GUI response) but has a price of potential slower form onload.

Well enough, heres the code samples and yes it's just samples. Copy and past to either onload or onsave of your form. Slight modifications are needed to fit your entity names or fields.

Hide "Delete" button from iframe entity depending state of picklist from main form

function myCustomLoaded()

{

if (this.readyState == "complete")

{

hideCustomDeleteButton()

}

}

 

function hideCustomDeleteButton()

{

var tmp = crmForm.all.new_dropdownvalue.SelectedText;

switch (tmp)

{

case "Stängt":

case "Förlorad Opportunity":

case "Not Choosen Partner":

//TODO: Change entity number 10001 to the one in your implementation

btnDelete = document.all.IFRAME_mycustom.contentWindow.document.all._MBdoActioncrmGrid10001delete;

if (btnDelete != null)

btnDelete.style.display = "none";

break;

}

}

 

//In onload of form

document.all.IFRAME_mycustom.onreadystatechange = myCustomLoaded;

//Just call hideCustomDeleteButton from onchange of your picklist

Hide "New" button depending state of main form

var navCustom = document.all.nav_opportunity_new_custom;

if (navCustom != null)

{

navCustom.style.display = "none";

//tab2 is used to place this frame

if (crmForm.all.tab2Tab.style.display == "")

{

if (crmForm.FormType == CRM_FORM_DISABLED || crmForm.FormType == CRM_READ_ONLY_TYPE )

//Read only no new button even if security saying something else

var url = "/userdefined/areas.aspx?oId=" + crmForm.ObjectId + "&oType=3&security=1&tabSet=opportunity_new_custom";

else

//Read from security and render depending role

var url = "/userdefined/areas.aspx?oId=" + crmForm.ObjectId + "&oType=3&security=852023&tabSet=opportunity_new_custom";

document.all.IFRAME_mycustom.src = url;

}

}

 

Validate rows in grid from onsave for child entity

//call checkRows in onsave

function checkRows()

{

var r = true;

var rows = document.all.IFRAME_mycustom.contentWindow.crmGrid.InnerGrid.rows

//Change to your cell to verify from grid

if (typeof(rows[0].cells[2]) == "undefined" || IsNull(rows[0].cells[2]))

return AlertMessage(0);

var total = 0;

 

var l = rows.length;

for (var i = 0; i < l; i++)

total = total + parseInt(rows[i].cells[2].innerText);

if (total != 5)

r = AlertMessage(total);

return r;

}

 

function AlertMessage(rows)

{

alert("You need to have atleast 5 rows to complete. Current sum of rows: " + rows + "!");

return false;

}

http://msdn2.microsoft.com/en-us/library/ms535258.aspx
http://msdn2.microsoft.com/en-us/library/ms534638.aspx