The release of Dynamics CRM 2013 brought a lot of interface improvements over CRM 2011; however it also made some things a little more annoying for developers. Fortunately some of these can be solved by creating bookmarklets.
One task that is made more difficult by the flat interface of CRM 2013 is grabbing the ID of the current record. It is can no longer be just grabbed from the URL of the form without popping it into its own window or using the email a link command bar button which requires more steps – annoying when doing this a lot to test an API for example.
To simplify this, create a new bookmark and set its URL to this code:
When pressed a prompt will open with the ID allowing you to copy it like this:
An important part of this code is the jQuery filter function on iframes, CRM 2013 on navigating to items simply creates an iframe and displays it, while setting the visibility of the previous frame to hidden. Then if the user presses the back button, it just unhides the previous frame. This means there could be many frames on the page, to find the correct one we find the frame that it currently visible before using the getId method to grab the record ID. We also perform a slice on the ID to get rid of the curly braces.
Another task made a little more difficult in CRM 2013 is when testing some SDK code or similar that has made some change to data on a record and you want to see the changes. In CRM 2011 you could just hit refresh however in CRM 2013 this can mess up the trail of iframes, breaking the back functionality. Instead we can combine the code for the previous bookmarklet with the supported code to refresh data on a form.
This will refresh the data on the form without reloading the form itself, preserving the navigation information and is quicker than having the whole page reload.
In CRM 2013 the new navigation bar has been a controversial feature, however when it becomes truly annoying is when using it with a sitemap layout that has not been optimised with it, which is common when upgrading CRM 2011 systems – I have seen one that took 15 clicks of the right arrow to get through all the items in the settings area. With these you just want to get to the solutions area right away to fix it, which is where this bookmarklet comes in.
This code makes use of the raiseNavigationRequest method that is used internally by CRM, using it is unsupported so be careful using it in any actual production code. An important part of this is the sitemappath query string parameter, this controls what area, sub area and then item the navigation displays, without this it will not update to correctly show that the user is viewing the solutions area.