Getting Parent Entity Information from child


In MS CRM 4.0 we used to get parent entity information using window.opener which is not there in CRM 2011 now. In CRM 2011 you can use below code

window.top.opener.parent.Xrm.Page

so using this statement you can get parent entity information and can fetch parent entity data, but sometime we also need to check parent entity name, let’s take an example of order, we can create order from opportunity form, we can create it from account form as well. So in that case if we need to check which is the parent entity in order form we can use below statement to check entity name

if(window.top.opener.parent.Xrm.Page.data!=null)
var EntyName=window.top.opener.parent.Xrm.Page.data.entity.getEntityName();

enjoy !!

Reference

Advertisements

9 Comments

Filed under MS CRM 2011

9 responses to “Getting Parent Entity Information from child

  1. As for me it is better to use WebServices (or EndPoints) to get this information.

  2. Guru Prasad

    Mahender, thanks for your post.. i got the same requirement.. you have save my time…

  3. This gets the entity name, but not a field name. How does that work?

  4. Prabhu

    Thanks, Saved my time…

  5. Yash

    Hi, Its not working in CRM 2013. Can you please suggest how to get the id of the parent record in the HTML webresource.

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