Disable parent form fields from related entities form

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…


Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

1 thought on “Disable parent form fields from related entities form”

  1. Apologize for my bad english, I deem its a nice piece of your writing. Famously I have faced alot of difficulties in this term but your article will definately help me in future. Say thank you You

    Like

Share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s