Saturday, October 11, 2014

CRM Bookmarklet To Customizations Page

There have been a few blog posts that have surfaced recently that add some nice shortcut functionality to CRM through the use of bookmarklets (browser bookmarks that execute JavaScript code).

A few of my favorites that I use almost on a daily basis:

Retrieve The Record ID
God Mode
Open Advanced Find
Change Field Labels To Schema Names

I thought I would offer one up of my own for quickly opening the Customizations page. Essentially when you open this up it's the same same as opening up any other solution except that this happens to be the "Default Solution". Whichever solution ID is specified in the URL dictates which gets opened. It would seem that in the handful of environments I checked the ID of the default solution is the same - but I thought it best not to take any chances and use the REST endpoint to retrieve the ID in order to construct and open the URL.

Create a bookmark and cut and paste the following into the URL:

javascript:(function(){var r=new XMLHttpRequest();r.open('GET',encodeURI(Xrm.Page.context.getClientUrl()+"/XRMServices/2011/OrganizationData.svc/SolutionSet?$select=SolutionId&$filter=FriendlyName eq 'Default Solution'"),true);r.setRequestHeader('Accept','application/json');r.setRequestHeader('Content-Type','application/json; charset=utf-8');r.onreadystatechange=function(){if(this.readyState===4){r.onreadystatechange=null;if(this.status===200){var t=JSON.parse(r.responseText).d;window.open("/tools/solution/edit.aspx?id="+t.results[0].SolutionId+"#","","width=1020, height=630");}}};r.send();})();

image

Update 10/29/2014

I found out from a reliable source the ID of the default solution is in fact a constant so therefore we can simplify the script down to this:

javascript: (function () {window.open("/tools/solution/edit.aspx?id=FD140AAF-4DF4-11DD-BD17-0019B9312238#", "", "width=1020, height=630");})();

http://msdn.microsoft.com/en-us/library/gg328257.aspx