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)

How can i retrieve current record guid in java script.

(0) ShareShare
ReportReport
Posted on by

Hello,

I'm  saveing my entity record using Xrm.Page.data.entity.save(); using javascript.
next line I want to retrive my current save record guid using 

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

It is giving me null value.

Please help me

How can i retrieve current record guid in java script.

Thanks 
Kashyap Diwan

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rahul G J Profile Picture
    605 on at

    Hi Kashyap,

    Unless the data is saved in DB, the system would not generate GUID for the record, it will be null.

    Follow this, this might help  you: 

    https://community.dynamics.com/crm/f/117/t/134587

    Hope this solves the problem.

    Regards,

    Rahul 

  • Suggested answer
    Alagunellaikumar Profile Picture
    6,212 on at

    At the time of new record Xrm.Page.data.entity.getId() because record is not yet save. If you want you go ahead plugin post operation and do your logic.

  • Suggested answer
    Kishor Kumar Profile Picture
    3,710 on at

    Once Record is Saved only, then only it  will create a new Guid and then you can retrieve.

    If you want retrieve the record after the Database transaction, as suggested by Alagu use the images in the plugin and you can get the data

    Check this

    crmbook.powerobjects.com/.../plug-in-images-pre-vs-post

    In Plugin too, once its saved you get the GUID using the Post Images in the plugin.

  • Verified answer
    Luke Sartain Profile Picture
    1,266 on at

    Before going down the plugin route try incorporating a callback function.  Not had time to test that it works myself but something like:

    var callBackSuccess = function(){

          var id = Xrm.Page.data.entity.getId();

    }

    var errorCallback = function(error){

         console.log(error.message);

    }

    Xrm.Page.data.entity.save().then(callBackSuccess, errorCallback);

    Alternatively you can try refreshing the form data after the save before retrieving the Id.

    Edit:  Here's the MSDN link. https://msdn.microsoft.com/en-us/library/dn481607(v=crm.6).aspx

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Try to use something like following:

    Xrm.Page.data.save().then(function(){

    var id = Xrm.Page.data.entity.getId();

    }, function(){

    //handle error here

    });

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi Kashyap,

    See: community.dynamics.com/.../177919

    Hope this helps.

  • P. R. M Profile Picture
    739 on at

    I have tried below method as suggested by Andrew Butenko. Its working for me....Thanks.

    Xrm.Page.data.save().then(function () {

                                       var id = Xrm.Page.data.entity.getId();

                                       //Send Email

                                       email.SendEmail(id);                                  

                                       Xrm.Page.data.refresh();

                                   }, function () {

                                       //handle error here

                                   });

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