We had a requirement like when a opportunity record is created from within an account form, the fields in the account form should get disabled.
This is the JavaScript that could be used for doing so, it is on the onSave event of the Opportunity form.
if (
(window.opener != null) &&
(window.opener.parent != null) &&
(window.opener.parent.document != null) &&
(window.opener.parent.document.crmForm != null)) {
var parentForm = window.opener.parent.document.crmForm;
if (parentForm.ObjectTypeName == "account")
{
// disabling field individually
parentForm.name.disabled=true;
// loop through all the fields and disable them
for(i=0; i<parentForm.elements.length; i++)
{
parentForm.elements[i].disabled=true;
}
// lookups need to be disabled separately
parentForm.parentaccountid.disabled=true;
}
}
Bye…
