Sonoma Partners Microsoft CRM and Salesforce.com Blog

JavaScript Bookmark Series – Part 2

A lot of times you’ll find yourself in need of an ID for a certain record.  You can navigate to that record in CRM and copy and paste the ID out of the URL but that can be a pain due to encoding. 

Here’s a quick and easy bookmark you can set up to alert the record ID and have it copied into your clipboard automatically:

javascript: var id = frames[0].Xrm.Page.data.entity.getId();  if (id) { clipboardData.setData("Text", id.toString()); alert(id); } else { alert('No id yet!'); }

And another one for the entity type code as a bonus…

javascript: var typeCode = frames[0].Xrm.Page.context.getQueryStringParameters().etc; if (typeCode) { clipboardData.setData("Text", typeCode.toString()); alert(typeCode); }

Enjoy!