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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Entity Id

(0) ShareShare
ReportReport
Posted on by 7,042

Hi Guys,

I'm facing some problem in Javascript in Online Account in CRM 2015.

When i'm trying to get EntityId using Ribbon button by JS, it's showing error "The object entity is undefined"

(i found this using developer tool). 

The code i used to get the EntityId is Xrm.Page.data.entity.getId()

Suggest me the exact code.

Thanks in advance

*This post is locked for comments

I have the same question (0)
  • Saroj Das Profile Picture
    3,355 on at

    HI Saravana, are you getting the entity name by using this. Please check .

    Xrm.Page.data.entity.getEntityName();

    Thanks.

  • Suggested answer
    Sayhaitokumar Profile Picture
    7,042 on at

    Hi Saroj,

    I need entity id only not the name

  • Saroj Das Profile Picture
    3,355 on at

    Hi Saravana, i wanted to know whether getEntityName also giving the same error. Please let me know.

    Thanks.

  • Suggested answer
    Hosk Profile Picture
    on at

    if you try to do this Xrm.Page.data.entity.getId() when you are not an an entity form then the getId() will return null and won't work, e.g. it throws the error

    "The object entity is undefined"

    This could be being called from the homepage in a grid view.

    you need to check if you are being called from a form

    something like this

    if (Xrm.Page.data != null)

  • Sayhaitokumar Profile Picture
    7,042 on at

    Hi Ben,

    You are right. I'm trying to get the Entity ID in the home page grid view.

    For that how to get ID of an entity?

  • Suggested answer
    Hosk Profile Picture
    on at

    I think you need to get CrmParamater and SelectedControlSelectedItemIds

    this msdn article explains how the logic of CrmParamater

    msdn.microsoft.com/.../gg309332.aspx

    this blog is CRM 2011 but this functionality hasn't changed

    stackoverflow.com/.../updating-field-in-crm-2011-through-javascript-from-ribbon-button-on-homegrid-vie

    this blog should help, it uses the ribbon workbench

    ribbonworkbench.uservoice.com/.../129783-pass-the-currently-selected-grid-row-s-to-a-custo

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans