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)

Xrm.Page.data.entity.getId() return value

(0) ShareShare
ReportReport
Posted on by

The return value of Xrm.Page.data.entity.getId() when calling from a "Create" form return null in Dynamics CRM 2011. However, after upgrading to Dynamics CRM 2013, it is returning an empty string instead of null. Is this expected beahviour?

*This post is locked for comments

I have the same question (0)
  • Aileen Gusni Profile Picture
    44,524 on at

    Hi Hakim,

    If you call once onLoad, The Guid would only return for the record that HAS been created or an existing record.

    So once you call to return value: Xrm.Page.data.entity.getId()

    from a Create form, the record has not been saved so that would return null.

    It will return null if you called on load on unsaved record.

    Yes, this is the expected behavior.

    To get the Guid you can call Plugin (after save, post create)  or instead, you put this to the Save Form, or using some validation onLoad.

    You can try to read this post:

    community.dynamics.com/.../134587.aspx

    It seems relevant as well for normal form.

    Hope this helps!

    Thanks.

  • Community Member Profile Picture
    on at

    [quote user="Aileen Gusni"]

    So once you call to return value: Xrm.Page.data.entity.getId()

    from a Create form, the record has not been saved so that would return null.

    [/quote]

    My problem is that in Dynamic CRM 2011 it is returning null (as expected) but in Dynamics CRM 2013 it is returning an empty string (i.e. ""). Did anything change in Dynamics CRM 2013?

  • Verified answer
    Mithilesh Kumar Profile Picture
    10,047 on at

    Hi Shahadatul,

    Tested it now and was amazed to find this, yes it returns "null" in CRM 2011 and "string" in CRM 2013. Thanks for finding it.

    However, I checked in MSDN also, and it states in all CRM 2011, CRM 2013 and CRM 2015 that getId() returns a String and not Null representing the GUID of the record.

    Generally getId() is used with existing record and that is managed by checking the Form Type (getFormType).

    But thanks for letting us know.

    Hope that helps

    Thanks

  • Community Member Profile Picture
    on at

    Thank you Guido Preite and Mithilesh Kumar for verifying the behavior I am noticing. I agree that getFormType should be used.

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