It is not an uncommon requirement to pull data for from the parent entity of the current record. In many cases, this child entity is only created from its parent so we can simply just reference the window.opener object to get a reference to the parent form.
An example would be creating a new Contact or Order from inside the Account form.
I got tired of writing this code over and over so yesterday I set down to attempt a solution that would be dynamic and I could just call from the Form’s OnLoad event. Here’s my solution:
function GetParentFormFieldValue(fieldName)
{
var retVar = null;
if (
(window.opener != null) &&
(window.opener.parent != null) &&
(window.opener.parent.document != null) &&
(window.opener.parent.document.crmForm != null)
)
{
eval("retVar = window.opener.parent.document.crmForm.all." + fieldName + ".DataValue");
}
return retVar;
}
It is used like this:
crmForm.all.name.DataValue = "New order for " + GetParentFormFieldValue("name");




