Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to get Entity Name or ID from Entity View in MS Dynamics CRM ?

Posted on by Microsoft Employee

Hi,

I want to get Entity Name from View of Entity in MS Dynamics CRM.

Here I am getting entity name by Xrm.Page.data.entity.getEntityName(); But it gives an error.

64285.Untitled.png

Can anyone suggest how to get Entity Name or Entity ID?

*This post is locked for comments

  • Suggested answer
    Oleksandr Domin Profile Picture
    Oleksandr Domin 16 on at
    RE: How to get Entity Name or ID from Entity View in MS Dynamics CRM ?

    Hi Chhaya,

    I'll slightly extend Nitin Verma's reply.

    You can either have a Home Page context or a Form context.

    Depends on the invocation location you can pass SelectedControl (would work on Home Page) and PrimaryControl (would work on the Form) into JS and in the script there should be two arguments in the function like OnLoad(formContext, homePageContext).

    When the function will be called out, one of two arguments would not be null so you would need to validate it and use not null one further.

    Some useful details are there in ms docs.

    Regards,

    Oleksandr

  • Jharana Baliyar Singh Profile Picture
    Jharana Baliyar Singh 2,665 on at
    RE: How to get Entity Name or ID from Entity View in MS Dynamics CRM ?

    Hi All,

    Even i want to know how we can get entity name from view areas ?

    But here Xrm.Page will not work.Is there any way so we can get atleast attribute name from view name using javascript ?

    Thanks,

    Jharana

  • Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: How to get Entity Name or ID from Entity View in MS Dynamics CRM ?

    Hi Chhaya,

    Why do you need to get the entity name of the view? Please explain the scenario.

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: How to get Entity Name or ID from Entity View in MS Dynamics CRM ?

    Hi Chhaya,

    As Nitin suggestion, this can be implemented by using JavaScript, but you will need to do this by adding a script library to your home page. In order to do this, you would need Ribbon Workbench to either create your own button, or customize an existing button and provide your JavaScript library as a reference, so that it is loaded when the home page view is loaded.

    You should be able to customize your script library to get an onload event there.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to get Entity Name or ID from Entity View in MS Dynamics CRM ?

    Thanks Nitin!

    I want to get CRM Entity name on onLoad of view page of CRM.  Please look at give screenshot.

    Suppose I clicked on Sales -> Account

    It shows default view of Account and I want to get Entity Name here.

    Can you please suggest me?

  • Suggested answer
    VermaNitin Profile Picture
    VermaNitin 455 on at
    RE: How to get Entity Name or ID from Entity View in MS Dynamics CRM ?

    Hi

    You won't get Xrm.Page here as it is available on form.

    If you have registered your script on ribbon button then you may pass the primary entity name as a crm parameter to your function using Ribbon Workbench.

    Hope it helps!

    Many thanks,

    Nitin Verma

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to get Entity Name or ID from Entity View in MS Dynamics CRM ?

    u seem to be non responsive after u get the answers.

    1)When ur questions are answered and if it solves ur issue make sure to verify the answer...if the answers provided doesn’t work atleast say so..

    2) before posting questions do check whether there are similar questions in forum.

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