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 8. May 2014

Sparkle XRM Code Snippets

If you are doing Sparkle XRM development then you'll find these code snippets I've created for VS2012 very useful. You can grab them from the master repository:
https://github.com/scottdurow/SparkleXrm/tree/master/Snippets
To start using these snippets you simply need to copy the contents of the Snippets directory and paste it into your profile directory at Users\<username>\Documents\Visual Studio 2012\Code Snippets

Using the snippets in Visual Studio is easy – When you are creating a new view HTML page just select all the default code and then type 'sparkle-view-page' followed by TAB. This will add the page snippet and allow you to TAB around the highlighted variable parts of the template which in this case are the name of your Client library (default Client.js) and the name of your View Class:


Once you've finished updating the parameters press Escape to exit the snippet edit.

You can then move the cursor to the line marked <!--TODO--> and add in your form by typing 'sparkle-view-form'. This allows you to enter the name of your view model instance and the title of your form section. Now you're ready to move to the TODO line and add the fields by typing the name of the field snippet and again pressing TAB and filling in the parameters.

Here is a list of all the snippets included:

  • sparkle-view-page – Adds the standard HTML View template
  • sparkle-view-form – Adds the standard Sparkle XRM Form scaffolding
  • sparkle-view-grid – Adds a Sparkle XRM grid
  • sparkle-view-text – Adds a text field
  • sparkle-view-numeric – Adds a numeric field and allows setting the max/min to a constant or view model field.
  • sparkle-view-optionset – Adds a optionset field and allows specifying the entity and attribute to grab the optionset metadata from.
  • sparkle-view-datetime – Adds a datetime field
  • sparkle-view-lookup –Adds a lookup field and allows specifying the search command to return the available records to select. The sparkle-viewmodel-searchcommand can be used to create the search command in the ViewModel Script# code.

There are also some snippets to add a View and ViewModel:

  • sparkle-view-class – Used to create a template view class that is referenced by your html view page.
  • sparkle-viewmodel-searchcommand – Used to create a command that is used to bind to a sparkle-view-lookup to be used when searching within the lookup field.

You'll find that using this snippets will speed up writing your code and reduce errors. Hope it helps!

@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!