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 !!
As for me it is better to use WebServices (or EndPoints) to get this information.
Mahender, thanks for your post.. i got the same requirement.. you have save my time…
Glad to know it helped you !!!
This gets the entity name, but not a field name. How does that work?
Hi, you can get entityid and query related entity based on the entityid
Thanks, Saved my time…
I am glad it helped you !!!
Hi, Its not working in CRM 2013. Can you please suggest how to get the id of the parent record in the HTML webresource.
For html page, you can simply write window.parent.Xrm.Page….