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 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
});
Hello,
Try to use something like following:
Xrm.Page.data.save().then(function(){
var id = Xrm.Page.data.entity.getId();
}, function(){
//handle error here
});
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
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.
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.
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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156