Crm 2013 Xrm.Page.data.entity.getId() doesn't refresh after save RRS feed

  • Question

  • on a new record, use the "Xrm.Page.data.entity.getId();" to get the value, which is blank...

    then save the record. try calling that line again (from an onchange field event) to see if the record is new or existing. the value is still empty. obviously if yourefresh (F5) or close and retrieve the record, it works fine.

    Since the onLoad method doesn't fire after a save, we need a reliable  way to know that the record has been saved in the database as we have plugins that fill certain fields with values and we don't want to have to tie the fields/handler on the form for each entity.

    Monday, December 2, 2013 7:51 AM

All replies

  • Hi,

    Just done a quick test on this and it seems fine using my Online org.

    I created a new lead, click save, and then made a call to:


    via the JavaScript console.

    It correctly returned the GUID of the new record.

    Hope this helps,


    Scott Durow
    Blog www.develop1.net    Follow Me
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Tuesday, December 3, 2013 1:32 PM
  • that didn't work (gave an error...working on a contact record...should be the same). also tried window.location.reload(true). doesn't work.
    Thursday, February 6, 2014 7:35 PM
  • so the ID is not available on the onChange event IMMEDIATELY following the save...however, if I call another method from the same onchange which has an async request, by the time the async request gets to the successful event handler (couple of seconds) , the ID is available...

    so it seems like the plumbing needs time to finish processing the explicit events from the save before it can refresh the ID or make available the ID to the javascript engine.

    In any event, the code is working now.

    Thursday, February 6, 2014 8:51 PM