Posted on 20. January 2015

The cream cracker conundrum (or customising the sub grid command bar)

I still find the streamlined user experience offered by the Command Bar a welcome change from the CRM2011 Ribbon. The sub-grid command bar is the only possible exception with the loss of the ability to add custom sub-grid buttons. There are only at most two buttons on a sub grid – 'Add' and 'Open Associated Sub-Grid'

The user must click on the 'Open associated sub-grid' button to show the full associated view and the full command bar with custom buttons. I say 'possible exception' because in fact there are still the same number of clicks involved (users had to click on the sub grid to show the contextual ribbon before) but it does feel as though we should have the ability to add buttons to the sub-grid command bar. I can think of some good reasons why this design decision may have been made (performance for one!) – but this post details what you CAN do to the sub-grid command bar.

Because the 'Open associated sub-grid' button is a bit of a mouthful, I'll refer to it from now on as the 'cream cracker' because it kind of looks like one and is equally a bit of a mouth full! (Thanks goes to my friends at the British Red Cross who first named it this way!)

Hiding buttons

We have established that you cannot add buttons to the form sub grid, but both the 'Add New' and 'Cream cracker' buttons are customisable in terms of their command and visibility (but you cannot change the image or the tool tip text).

To hide the sub grid buttons you have the following options:

  1. Hiding based on a security role (if the user does not have access to append a record to the parent or create new records of the sub grid type, the 'add new' button will be invisible
  2. Hiding all of the time using a 'Hide Action'
  3. Hiding conditionally using a security role
  4. Hiding conditionally using a custom JavaScript rule.

A common requirement is to hide the Add New button on a sub-gird until a specific criteria is met on the parent form. The standard ValueRule cannot be used because this rule will only work when the command button is added to a form command bar. So to achieve the conditional show/hide we must use a Custom JavaScript Rule.

The first hurdle is to determine which button needs to be customised. The sub grid 'Add New' button calls a different command depending on the nature of the relationship.

If you have a foreign-key attribute on your child entity that is marked as Field Requirement = 'Optional' then the Add New button will be the AddExistingStandard since it allows you to search for an existing record first. If the Field Requirement = 'Business required' then the button will be AddNewStandard

 

 

Once you've identified the right button, you can then open the ribbon workbench and click Customize Command and add the Value Rule as described by my user voice article.

Changing the command actions

Although we cannot add new buttons (did I mention that?!) we can change the command actions that either of those two buttons call. Since we can't customise the button, the only option here is to customise the command and change its behaviour in a very similar way to adding custom enable rules.

  1. Right click the button in the Ribbon Workbench and select Customise Command
  2. Expand the command in the Commands node in the Solution Elements panel and select the command that has been created for you to customise.
  3. Right click Edit Actions and you can simply delete the standard action and add your own custom ones.
  4. Remember to mark all the enable and display rules that you don't want to customise as IsCore=True.

Once such use of this technique is to replace the standard add new button with a custom dialog.

Refreshing the sub grid Command Bar

You will find that when the form is loaded and the sub grid is refreshed for the first time the EnableRules are evaluated. If however the conditions for the EnableRules change (e.g. a value changes on the parent form) the sub grid command bar will not automatically refresh to reflect the new state. Upon adding or deleting rows in the sub grid the command bar is refreshed – but this isn't much use in this case.

The main form command bar can be refreshed using Xrm.Page.ui.refreshRibbon() however this will not refresh sub grid command bars. Instead, we can add an onchange event to the fields that are used in our ValueRule and call:

Xrm.Page.data.save();

This will refresh the sub grids and re-evaluate any of the EnableRules however it will also save any other dirty attributes and so should be used with caution if you do not have auto-save enabled.

Responding to new/deleted rows in the sub grid

Since the sub grid command bar is refreshed when new rows are added or deleted we can use the fact that the EnableRules will be re-evaluated to call custom JavaScript when the sub grid changes. This simulates a sub-gird onchange event and was first described by James Wood's blog post for CRM2011. He states on his blog that this technique doesn't work for CRM2013 – however if we add the custom EnableRule to the existing command (rather than use a new button as James describes) then this technique works well in CRM2013 and CRM2015. So we can customise the command for the Add New or cream cracker and add a Custom JavaScript Enable Rule that always returns true in just the same way that you might use the EnableRule to dynamically show/hide the button but rather we just run our onchange code.

Perhaps in the future there will be more possibilities but for now that about sums up the possibilities for customising the sub grid command bar.

@ScottDurow

Posted on 1. January 2015

Ribbon Workbench 2015 (Happy New Year!)

Happy New Year – I hope 2015 will bring you lots of good things. Dynamics CRM 2015 upgrades are rolling out to Dynamics CRM online organisations with rapidly increasing frequency and so I have updated the Ribbon Workbench for 2015 support. You will see a new update notification when you next open the Ribbon Workbench and you can let the auto update do the download and install for you. If you would rather install manually you can download and install over the top of the previous version.

Automatic update is mandatory after 10th January – why?

You'll have the option to update before the 10th of January and then you'll be forced to update after that. Some people have asked me other the last couple of years why I roll out these mandatory updates. Initially this was about ensuring that the beta version was updated with any bug fixes but since then it has been a way of ensuring that I keep rolling out new version. I set a 6 month release cycle target so that even though I roll out minor updates I have to roll out at least one mandatory update every 6 months! I hope you don't mind being forced to update too much – I certainly feel that the benefits outweigh the downsides and it keeps me on my toes J

Command bar 2015

The good news about the 2015 command bar is that after the big shift from the ribbon in CRM2013 there haven't been any significant changes. All of your ribbon xml customisations in CRM2013 will remain to work in CRM2015 provided that any JavaScript you are calling in your commands doesn't use any deprecated SDK elements. If you compare the RibbonXml XSD between the CRM2013 and CRM2015 SDKs you'll see that they are in fact identical!

All the best for 2015!

@ScottDurow

Posted on 29. May 2014

And then there were seven!

If you've updated to the CRM2013 Spring '14 Wave (Service Pack 1) I think you'll agree that it contains some pretty awesome features.

You can read a good roundup of the developer features in the SDK (http://msdn.microsoft.com/en-us/library/gg309589.aspx#BKMK_NewInSpring2014) but have you noticed that there is a little less white space across the top of your forms? This is because the Command Bar now shows 7 rather than 5 buttons before buttons are added to the ellipses overflow.

It is worth noting that the number of buttons that are displayed before the overflow is not (yet?) configurable and nor can you revert back to displaying only 5 (pre SP1). That said, I really appreciate this little change that is a result of the product team listening to feedback from users. What's more it has no impact on the Ribbon Xml or Ribbon Workbench.

You might like to read more about the Command Bar in my post from way back when CRM2013 was first released.

@ScottDurow

Posted on 5. May 2014

Create a command bar button for your custom activities

When creating a new custom activity entity you are presented with a great many checkboxes to choose from. One of these checkboxes is 'Display in Activities Menus' that will ensure that the activity type is included in the Activities Menu on records

The Custom Activities flyout menu is a dynamically generated menu so that if you load up an entity in the Ribbon Workbench and expand this button you won't see any menu items. This has been the subject for confusion for users who are trying to move this button out of the sub menu and put it on the main Command Bar as a short cut for uses. Since the menu is created dynamically at run time there is no button to customise and move. This post shows you how to create a custom activity button on the opportunity form.

1. Determine the Entity Type Code of your custom activity.
Each custom entity has an Entity Type code. This integer value is different to the entity logical name and could be different on each organization you deploy your solution. We need to know this entity type code in order to create a new record of a specific entity type.

To find the value, create a new record for your custom entity in Internet Explorer and press Ctrl-N (opens a new window with Url visible) and copy the URL. This should look something like:

http://server/Org/main.aspx?etc=10005...

You need to note the etc number for later.

2. Install Ribbon Workbench

You'll need to install the Ribbon Workbench as described by 'Getting started with the Ribbon Workbench'

3. Create and open a solution containing the Opportunity Entity

The Ribbon Workbench requires a solution to load that contains the entities that you wish to work on. Since we are adding the new button to the opportunity entity, add it to the solution – only add the entities you need to speed up the solution load/publish time. When you first open the Ribbon Workbench it will allow you to select your new solution.

4. Click on the 'Ribbon' tab and change drop down in the top right to 'Form'

We need a template command to use and so we select the 'Ribbon' view rather than the Command Bar view so to locate the 'Task' button on the Form ribbon.

5. Select the 'Add' tab and then right click on the 'Task' button and select 'Customise Command'

The Task button is located on the 'Add' tab. Using 'Customise Command' creates a copy of the add task command that we can change to reference our custom acitivty.



6. Expand the Commands node to see the customised command and select 'Mscrm.AddTaskToPrimaryRecord'.
7. Rename the command to be something like 'Mscrm.AddCustomActivityToPrimaryRecord'

By renaming the command we are creating a new command specifically for our new button, rather than customising the existing one.

8. Expand the Command and JavaScript command and change the Int value to be the Entity Type Code of your custom activity

Remember that the entity type code is unique to your custom entity – but it could change between deployments.

9. Right click on the command and select 'Edit Display Rules' and Remove the 'HideOnCommandBar' rule

Since the Task button only shows on the legacy ribbon, we need to change the command so it also shows on the command bar by removing this display rule.

10. Select the 'Command Bar' tab and drag a button onto the Form command bar

11. Set the Command to be your new custom command (e.g. Mscrm.AddCustomActivityToPrimaryRecord)

12. Set the image16 to be /_imgs/ribbon/AddActivity_16.png (or a custom image you have for your entity)

13. Expand the 'Display Rules' and set the 'IsCore' property to 'True' on each Display Rule.

14. Expand the 'Enable Rules' and set the 'IsCore' property to 'True' on each Enable Rule.

By setting the 'IsCore' property to true, we only reference them rather than redefining them.

15. Publish your customisations

16. Test the new button on the opportunity form!

Posted on 28. February 2014

Ribbon Workbench updated - getServerUrl is removed in CRM2013 UR2

With CRM2013 UR2 being released very soon I have made an update to the Ribbon Workbench that you'll be prompted to install by the auto update when you next open the Ribbon Workbench. I strongly advise you to install this update before you install UR2 otherwise the Ribbon Workbench will no longer work, and you'll need to re-download and re-install.

This is because when I updated the Ribbon Workbench for CRM2013 I retained the use of getServerUrl – the update now uses getClientUrl because UR2 has removed getServerUrl altogether.

getServerUrl was deprecated back in CRM2011 with UR12 so it's probably about time it was removed anyways!

Posted on 5. December 2013

Form File->Properties dialog in CRM 2013

One of the lesser known features of CRM 2011 was the File->Properties dialog that you could view on a record form. It would look something like:

This dialog was very useful for finding out the effective permissions of the current user on a particular record but in CRM 2013 it is no longer present in the user interface – but it is still there in the background!

If you used to use this dialog in CRM 2011 I've created a managed solution that provides you with a Properties button on the Command Bar that shows the CRM 2013 version of this dialog.

FormPropertiesButton_1_0_0_0_managed.zip (2.39 kb)
(The usual disclaimer applies)

After installing the solution, you should see a new button in the Command Bar overflow menu:

The dialog looks like this:

The only down side is clicking OK gives the 'Are you sure you want to navigate away from this page' dialog.

Hope this helps.

@ScottDurow

 

Posted on 21. November 2013

Restore Add Activity buttons in CRM 2013

By default the CRM2013 form Command Bar doesn't show the old 'Add' tab buttons for activities. The intension is that users will want to use the new Activities Tab control on the forms as show below:

In an upgrade from CRM 2011 you may want to preserve the add activity buttons on a form. This post describes how you can easily bring back those add activity buttons using the Ribbon Workbench.

1) Create a solution containing the entities that you wish to restore buttons for. I am using the Account entity for this post.

2) Open the solution containing the Account entity in the Ribbon Workbench for CRM 2013 and select the 'account' entity if not already selected. You will see by default the Command Bar is selected.

3) Select the Ribbon tab to show all the buttons that are defined.

4) Select the 'Form' ribbon using the drop down in the top right corner of the design surface and then select the 'Add' tab. You should now see the CRM 2013 activity buttons.

5) Right click on the phone call button and select 'Customise Command'

6) In the 'Solution Elements' panel expand the 'Commands' node and select 'Edit Display Rules'

7) Select the 'Mscrm.HideOnCommandBar' rule and click 'Remove'. If you do not see this rule, then it is likely that you have forgotten to select the 'Form' ribbon in step 4 above.

8) Click OK and then repeat for each of the add buttons that you want to restore.

9) Since we are not customising the enable/display rules – only the command, expand the Enable Rules and Display Rules node, and for each rule that is prefixed with Mscrm, select and set the 'IsCore' property to 'False'.

Display Rules

  • Mscrm.HideOnCommandBar
  • Mscrm.AddActivityToPrimary
  • Mscrm.WriteActivityPermission

Enable Rules

  • Mscrm.AppendToPrimary
  • Mscrm.FormStateExistingOrReadOnly

10) Click 'Publish' and your form should now show the activity buttons who's command's you customised.

 

@ScottDurow

Posted on 24. October 2013

Upgraded to Orion? Upgrade to Ribbon Workbench for CRM2013

If your Dynamics CRM Online instance has been upgraded to Orion (CRM2013) you will need to upgrade to the latest version of the Ribbon Workbench for CRM2013. Since the Ribbon Xml Schema has changed slightly with CRM2013, the old version will no longer work.

Upgrade Steps:

  1. Open Settings->Solutions.
  2. Locate the Ribbon Workbench solution and click 'Delete'
  3. Download and Import the Ribbon Workbench for CRM2013.
  4. Refresh your browser and navigate to Settings->Solutions where you will find the new Command Bar button:

Further reading:

  1. Ribbon 'XML' Workbench for Dynamics CRM 2013 with a silent 'XML'!
  2. 4 things you need to know about the Command Bar
  3. Restore a Button that has been removed from the CRM 2013 Command Bar

 

Posted on 20. September 2013

4 things you need to know about the Command Bar

This post provides the important information you need to know in order to transition to customising the Command Bar in Dynamics CRM 2013.

1. The Command Bar is a Ribbon in disguise!

The Ribbon Bar in Dynamics CRM 2013 to a certain degree has been replaced by the Command Bar but it still exists on non 'refreshed' entity Forms such as Connection Form and Price List Form, and is still present on all home list view grids in Microsoft Outlook.

The Command Bar is actually the same Ribbon structure but rendered differently in the User Interface. Although the Command Bar has no visual concept of Tabs, Groups or Layouts and there is no dynamic resizing and scaling, it still requires the Ribbon Diff Xml with these constructs to function. Using the Ribbon Workbench for CRM2013 will allow you to still edit these structures, but view in both the Command Bar and Ribbon display format.

2. Disabled Buttons are hidden

The Command Bar will only show 5 controls at any one time before they are added to the 'overflow' section. This deliberate constraint means that you will need to think carefully about what the user really needs on their command bar. Initially this may sound like a tricky problem but the Command Bar will not display a disabled button – it will always hide it – which means that the 5 buttons being shown will dynamically change depending on what buttons are available to the user. This is a significant improvement over the Ribbon that would always look cluttered even if there were very few buttons enabled for use.

To work with the 5 control constraint you can use fly out and split buttons to group commands together and not be moved to the overflow. The Overflow menu can also have fly out controls that open to the right rather than pulled down.

3. No contextual Sub Grid Controls

CRM2011 form Sub Grids used to dynamically swap in the Sub Grid Ribbon at the top of a form when a sub grid was selected. This allowed access to the sub grid entity commands directly from the parent entity form but often left a user confused. This functionality has been removed in CRM 2013 and the primary entity Command Bar now always is shown at the top of the form. A new 'mini' Command Bar is shown above each form Sub Grid showing only the 'Add' and 'Open Associated Sub Grid' buttons with the Delete button shown next to each record. If you want to access all of the sub grid buttons you must use the 'Open Associated Sub Grid' button that opens the entire page into the Sub Grid list view. To return to the form you must click on the name of the record in the Nav Bar. You cannot customise this mini Sub Grid at this time other than overriding the 'Add' and 'Delete' command - you cannot add buttons or change the icons of buttons on the mini Sub Grid, but full customisation is supported on the full Sub Grid Command Bar.

4. Controlling Visibility of Controls on the Command Bar

The visibility of a control on the command bar is defined using a new Display Rule named 'CommandClientTypeRule'. Controls will only show on the Command Bar if their associated Command has no CommandClientTypeRule Display Rules or it has a CommandClientTypeRule is added with Type=Refresh.

The Types property can have the following values:

Modern

The control is visible in the Tablet client

Refresh

The control is visible in the Command Bar

Legacy

The control is visible on ribbons of non-refresh entities or in list views presented in Microsoft Outlook.


There is a built in Display Rule that is used to hide system buttons from the Command Bar named 'Mscrm.HideOnCommandBar' that has a 'CommandClientTypeRule' with Type=Legacy. Commands with this Display Rule will not be visible on the Command Bar. You can remove this display rule from command to bring back buttons that were hidden by default. I have created instruction on how to do this.

Clean and Responsive

These 4 points will make planning & designing your CRM2013 solution easier and I'm sure you'll soon be loving the clean and responsive user experience that the new Command Bar gives.

@ScottDurow

Posted on 6. September 2013

How to restore a hidden button on the CRM 2013 Command Bar

The new Dynamics CRM 2013’s command bar has deliberatly limited space for buttons due to the ‘intentionally constrained’ user interface design. The idea being that if you limit the space for buttons, then designers will be forced to only show those that are absolutely necessary and the user experience will be improved. As result, many of the buttons from the CRM 2011 Ribbon Bar have been removed from the CRM 2013 Command Bar.

The CRM2011 Ribbon Buttons are still there, but hidden using a new RibbonXml Display Rule named 'Mscrm.HideOnCommandBar'. This article shows you how to restore those buttons to the Command Bar that your users absolutely must have using the Ribbon Workbench for CRM2013.

1. Create a solution containing the entities that you wish to restore buttons for. This example uses the ‘Case’ entity, and we are restoring the ‘Connect’ button on the ‘Form’ command bar.
Before customising, the Form Command Bar looks like the following:

You’ll notice that only 5 buttons are shown until buttons are added to the ‘overflow’ menu. The ‘Connect’ button is not here since it was deemed unessential.

2. Open the solution containing the Case entity in the Ribbon Workbench for CRM 2013 and select the ‘incident’ entity if not already selected. You will see by default the Command Bar is selected.
 

3. In order to locate the button we want to restore, click on the ‘Ribbon’ selector to show the Ribbon. This will show the Ribbon Design surface.

4. Select the ‘Form’ ribbon using the dropdown on the top right of the design surface, then select the ‘Connect’ button and Right-Click ‘Customize Command’

5. Locate the Customised Command in the ‘Solution Elements’ tab under ‘Commands’

6.  In the Edit Display Rules dialog, select the ‘Mscrm.HideOnCommandBar’ rule and click the ‘<Remove’ button.

7.  Important: Locate the following Display Rules, and set the ‘IsCore’ property to ‘True’ – this will prevent them from being customised as well:

a.      Mscrm.HideOnCommandBar

b.      Mscrm.CreateConnection

c.      Mscrm.IsConnectionsEnabledPrimary

d.      Mscrm.HideOnModern

8. Important: Locate the ‘Mscrm.FormStateExistingOrReadOnlyOrDisabled’ Enable Rule, and set the ‘IsCore’ property to ‘True’

9. Click ‘Publish’

10 Now when you refresh the Case Form, you will see the Connect button again.

11  You’ll notice that only the default button is shown – so if you use the drop down, you’ll only get the ‘Connect to Another’ option. To enable the ‘To Me’ button repeat the process for the ‘To Me’ button:

Remember to make sure that only the buttons that are really needed are included - the Command Bar has been constrained intentially to give your users the best experience.

@ScottDurow