I had previously written an blog about this
https://crmbusiness.wordpress.com/2011/02/21/crm-2011-quick-way-to-find-a-guid-using-a-crm-form/
and the method involved getting the url and copying out the guid from it, which is a bit slow and painful, particuarly on non default entities because there are two guids in the url and I keep forgetting which one I need.
Also someone informed the url is no longer displayed in CRM 2013!
Then a comment from Michael Blackburn gave me a much simplier solution, which I thought I should share because it’s certainly made my life a lot easier.
Press F12 to open the developer console, Click the script tab, and in the bottom right, next to the >> type in:
frames[0].Xrm.Page.data.entity.getId()If you need to call any Xrm function from the context of the javascript console, you can do so by prefacing it with frames[0].
Here is video link, showing you how to get the guid in Chrome and IE in CRM 2013
In Internet Explorer I use favorites to inject JavaScript into the form and get the GUID.
Here is the “URL” I use to inject the JavaScript (I press CTRL + I to access the favorites if no menu is available)
javascript:alert(frames[0].Xrm.Page.data.entity.getId());
I can then copy the content of the JavaScript alert pop-up.
LikeLike
And if you’re using the Outlook client for CRM, you can press [Ctrl]+N to open the current form in Internet Explorer.
LikeLike
you can run cd(frames[0]) before running this. this eliminates the need to constantly prefix frames[0] when executing commands from console. in chrome you can simply choose the frame on which the js will be executed, but not in IE.
LikeLike
Thank you, thank you, thank you!
You just saved me hours of misery 🙂
LikeLike
Doesnt work for me
Unable to get property ‘entity’ of undefined or null reference
LikeLike
Mike, I was getting this error too – in IE11, in the console window, make sure your target is _top:main.aspx and just enter Xrm.Page.data.entity.getId() This worked for me.
LikeLike
This page is my browser’s top most crm favourite. Thanks Hosk.
LikeLike
There is an easier way using javascript bookmarklets, I will blog about it this week or next week.
LikeLike