Advanced Find from Form Command Bar in Dynamics CRM 2013

Paul Nieuwelaar, 18 May 2014



Since CRM 2013 now opens forms in the same browser window as the view, it makes it more difficult to access advanced find, which by default is only available from list views.

In this blog post I will describe how to customize the command bar to add an advanced find button onto all forms in the system, so that advanced find can be launched from anywhere, whether on a view or a form.

First you need to create a solution with the Application Ribbons, and a javascript web resource.



Add the following function into the web resource, which is what will be used to launch the advanced find window:

function openAdvFindCustom(etc) {
    var oUrl = Mscrm.CrmUri.create("")
    oUrl.get_query()["EntityCode"] = etc;
 
    var oMainUri = Mscrm.CrmUri.create("/main.aspx");
    oMainUri.get_query()["pagetype"] = "advancedfind";
    oMainUri.get_query()["extraqs"] = oUrl.get_queryString();
    openStdWin(oMainUri, "_blank", 900, 600);
}

Next you need to customize the command bar XML. Using the CRM 2013 Ribbon Workbench will make this easier. Edit the solution to export the ApplicationRibbon. This is the global ribbon which will be applied to all entities.

Add a new button onto the Form command bar. I’ve added mine just after the ‘Delete’ button. You can copy the icons, labels, and description from the CRM advanced find button on the home command bar.

Finally you need to create a custom command to open the JavaScript function openAdvFindCustom from the web resource, and pass in the PrimaryEntityTypeCode parameter.



Take a backup of the solution before publishing, just in case something goes wrong so you can roll back. Then hit publish at the top of the ribbon workbench. Once the changes are published, refresh CRM and open a form. You should see the new Advanced Find button, which when clicked will open a new Advanced Find window just like it does from the list view.



Note that this JavaScript is unsupported, and could break with future updates.