Archive for May, 2014

In CRM 2013 we have business rules defined for each entity.

If we want a global view of all business rules in our system however, it’s not obvious where to find these.

If we pull up an Advanced Find, we can query Processes where Category = PBL to pull up a list of all business rules in our system.

This will include the status and entity it’s on.

While this is great for listing all your business rules, if you try and open one from here you will receive an error.

You can activate and deactivate, just not open.

If you need to edit or create any, you will still need to go through the solution and entity.

While testing some logic I noticed a method to ‘enable’ fields that are set as read only through the form.

When a field is set as read only, you would expect that a user can never enter a value (without using JavaScript or devtools to enable them).

Here’s what I did:

  1. Open the record
  2. Deactivate the record
  3. Activate the record
  4. Change any disabled fields which are now editable
  5. Refresh the form and the values will be saved and read only again

This is with CRM 2013 rollup 2.

Before:

After:

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.

If you want a more supported solution, you can call the default advanced find button function directly, which means you don’t need your own web resource and JavaScript. However note that this method won’t open advanced find to the entity you’re on, instead it will always default to the first entity in the list. You will still need to create a custom command, with the Function Name as Mscrm.RibbonActions.openAdvancedFind and the Library as /_static/_common/scripts/RibbonActions.js. For this you don’t need to pass any parameters. I’d say this is still unsupported, but it’s using a CRM function instead of a custom one, so it’s a bit nicer if you don’t mind it not opening the entity you’re on.