Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Get parent entity logical name by fieldname using javascript or c#(CRM sdk)

Posted on by Microsoft Employee

Hi all,
I need to get parent entity details on child form like:
1.logical name.

2.Id.

I have searched on google and got parent entity Id but not parent entity name.

it is possible to got parent entity logical name by using java script or C#(CRM sdk)?

*This post is locked for comments

  • Suggested answer
    Sreevalli Profile Picture
    Sreevalli 3,256 on at
    RE: Get parent entity logical name by fieldname using javascript or c#(CRM sdk)

    Akram,

    Correct me if I am wrong, Mapping entity saves user input and from which you want to copy one of the lookup field to another entity's lookup field? If my understanding is true, then how you are copying/mapping? using workflow or javascript of just relationship mapping.

    note,

    1. You can only copy/map the fields when it match the data type (in case of lookups - both should associate with same entity)

    2. we can get lookup reference recordID, name and referring entity name from above code. but if you are looking for any field names (you mentioned above -lookup field name(only field name not other information) ) should be fetched from metadata.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Get parent entity logical name by fieldname using javascript or c#(CRM sdk)

    Thanks Sreevalli,

    I need to mapping for lookup,lookup field name(only field name not other information) is defined by user in mapping entity so I can map data that come form service for this lookup.

  • Suggested answer
    Sreevalli Profile Picture
    Sreevalli 3,256 on at
    RE: Get parent entity logical name by fieldname using javascript or c#(CRM sdk)

    To find the other details you have to use the code snip which I share earlier, trigger Javascript on load and on change to see the results.

    but could you elaborate the retirement, what you need to do with these details?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Get parent entity logical name by fieldname using javascript or c#(CRM sdk)

    yes,

    but I have only lookup field name so can I get other details of lookup  by its name?

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Get parent entity logical name by fieldname using javascript or c#(CRM sdk)

    Hi Akram,

    May I know what is your business scenario and specific requirement ?

    When you are saying you have a child form so you should have lookup field  reference of the parent entity in the child entity form , so you can simply get the  lookup id , name , logical name as suggested above.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Get parent entity logical name by fieldname using javascript or c#(CRM sdk)

    Thanks for reply again.

  • Sreevalli Profile Picture
    Sreevalli 3,256 on at
    RE: Get parent entity logical name by fieldname using javascript or c#(CRM sdk)

    No, you can see these detail only if the lookup is filled with data

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Get parent entity logical name by fieldname using javascript or c#(CRM sdk)

    Thanks Sreevalli for reply,

    Can I get ParentEntityType  on new record creatation ?

  • Suggested answer
    Sreevalli Profile Picture
    Sreevalli 3,256 on at
    RE: Get parent entity logical name by fieldname using javascript or c#(CRM sdk)

    Hi,

    The reference between parent and child is a lookup field on child form. so we have to find the parent details using the lookup field itself

    if (Xrm.Page.data.entity.attributes.get("fieldname").getValue() != null) {

              var parentID = Xrm.Page.data.entity.attributes.get("fieldname").getValue()[0].id;

              var parentName = Xrm.Page.data.entity.attributes.get("fieldname").getValue()[0].name;

              var ParentEntityType = Xrm.Page.data.entity.attributes.get("feildname ").getValue()[0].entityType;

          }

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans