jump to navigation

Microsoft Dynamics CRM 4.0 Accessing Parent Form July 28, 2010

Posted by jarrettexpertcrm in Microsoft CRM General.
Tags: , , , , , , , , , ,
trackback


In some cases you made need to have a code fire based on information from the parent form of that entity. For example, lets say you have a checkbox on the Order form that has values “Approved” and “Unapproved”. You need to have the Product lookup field disabled on the Order Product entity if the value “Unapproved” is checked. This is just an example, there are many other scenarios where this might come in handy. Place this code onload of the child entity.

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;
var formType;

switch(parentForm.FormType)
{

case 1:
formType = “Create Form”;
break;

case 2:
formType = “Update Form”;
break;

case 3:
formType = “Read Only Form”;
break;

case 4:
formType = “Disabled Form”;
break;

case 5:
formType = “Quick Create Form”;
break;

case 6:
formType = “Bulk Edit Form”;
break;

default:
formType = “Undefined Form Type”;
break;
}

if (parentForm.ObjectTypeName == “PARENTENTITY”)
{

if(parentForm.all.FIELD.DataValue == VALUE)

{
//PLACE FUNCTION FOR CHILD ENTITY HERE

}

}
}

Enjoy!

For more information about Dynamics Four or to contact us please visit http://www.dynamics4.com

Advertisements

Comments»

No comments yet — be the first.

Leave a Reply

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

%d bloggers like this: