web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to get Parent Entity Logical Name

(0) ShareShare
ReportReport
Posted on by 3,315

Hi all,

I have two Entities A and B. In A entity I have a lookup of B. Now I am opening B Entity Form from A(Both QC and Main form). Now I want parent entity logical name from Entity B. I mean how can I get from which Entity I am opening current form.

I already used  window.top.opener.parent.Xrm, window.top.opener.Xrm.Page.data.entity.attributes.get() etc. Nothing is working for me. 

Please suggest me how can I get this using Javascript?

Thanks in Advance.

Shiva

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    sandeepstw Profile Picture
    4,601 on at

    Hi Shivaram,

    Review these articles might help you:

    msdynamicscrmblog.wordpress.com/.../javascript-references-in-microsoft-dynamics-crm-2013

    www.magnetismsolutions.com/.../access-microsoft-dynamics-crm-quick-view-form-attributes-using-javascript

    if you find this answer valuable, please mark as verified.

    Thanks,

    Sandeep

  • Suggested answer
    tpeschat Profile Picture
    4,930 on at

    Hi,

    maybe this article will help:

    www.c5insight.com/.../use-javascript-with-parent-entity-forms-to-update-and-retrieve-dynamics-crm-records.aspx

    Thomas

  • Conor Gallagher Profile Picture
    715 on at

    Hi Shiva,

     

    So, just to clarify a few things first as the use of the terms Entity A and B is confusing me. Let's call them account (Entity B) and contact (Entity A) just for the sake of your example.

     

    You have 2 entities, Contact and Account. On the Contact entity you have a lookup to Account.

    Next, you are opening up the Account form (i.e. trying to create an account?) from the context of an existing contact...By this do you mean clicking on the Lookup button and then clicking on the "+new" button available in the lookup dropdown? If this is correct then the following used to work... but as you probably found no longer does:

    window.top.opener.parent.Xrm.Page.data.entity.getEntityName()

    For some reason in 2016 the data on Page is returned as null. I guess they've changed how you get this in 2016, I'll need to go investigate how you get it these days.

     

    On the other hand, do you mean accessing entities the other way round? I.e. You are on the account form -> and on the account you have the contact grid open? From there you are clicking on the + (add new contact) button. From here you could use the out of the box attribute mapping. By default CRM will have populate the account lookup so you can grab the entity type from that lookup attribute.

     

    If you can clarify the above then I can do a bit more digging for you.

  • Conor Gallagher Profile Picture
    715 on at

    Actually, figured it out. If you are using CRM 2016 this seems to be the new way to get the parent context:

    window.top.opener.frames[0].Xrm.Page.data.entity.getEntityName()


    Let me know how you get on with that.

  • shivaram Profile Picture
    3,315 on at

    Hi Conor, Thanks for your reply. You are correct, data is giving null value there in 2015 also. And some where in this community, I read that 'opener' will work only if you are try to create entity in new window. So I disabled +new button On lookup. But the problem is, while selecting lookup field, we are having one link "lookup more records". There again we are having New button. So from there I am trying to create account entity.

    I will try this answer. And probably I can test that on Monday. Hope it helps me. Thanks buddy.

  • shivaram Profile Picture
    3,315 on at

    Hi Conor,

    No luck. :( . It is giving null reference only. I am using 2015.

    window.top.opener.parent.Xrm.Page.data.entity.getEntityName()

    In this script, window.top.opener.parent.Xrm.Page.data is null

  • Suggested answer
    tpeschat Profile Picture
    4,930 on at

    Hi,

    this should be possible with Xrm.Page.context.getQueryStringParameters();

    (pType, partyid, partyname) ...

    cvanochten.wordpress.com/.../hello-world

    Hth Thomas


    No, it isn't... just tried it out myself. Sorry

  • shivaram Profile Picture
    3,315 on at

    Its Okay Thomas.Thanks for reply.  I tried links which were provided by you, but unfortunately it is not working.

  • Suggested answer
    Community Member Profile Picture
    on at

    Hello,

    You can try below code:

    window.top.frames.parent.frames[0].Xrm.Page.getAttribute("name").getValue()

    // JavaScript source code


    function onLoad()
    {

    alert( window.top.frames.parent.frames[0].Xrm.Page.getAttribute("name").getValue());
    }

    Thanks,

  • Conor Gallagher Profile Picture
    715 on at

    Just to confirm, have you tried your code with the frames[0] as per my second message above?

    window.top.opener.frames[0].Xrm.Page.data.entity.getEntityName()

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans