Sonoma Partners Microsoft CRM and Salesforce Blog

Project Siena First Impressions

Today's guest blogger is Corey O'Brien, VP of Software Development at Sonoma Partners

Microsoft just released "Project Siena" yesterday, an app designed to create Windows 8 apps quickly and easily. While it's certainly not a replacement for Visual Studio and other full-fledged development environments, it may still have its place with the right use case. Watch the video for a more detailed impression.



Using LINQPad to Debug CRM Plugins

Today’s guest blogger is John Trujillo, a Developer at Sonoma Partners.

LINQPad is one of my favorite tools for developing .NET code (especially plugins). With the magical Dump() method and the ability to test code snippets without ever having to create a new VS project, it is a great way to explore .NET libraries and prototype some of your ideas. If you’re new to LINQPad, you can view samples in the bottom left corner of the application and begin with the “LINQPad 5 minute introduction” to help get you started.

I’ve recently learned that, combined with Visual Studio and the System.Diagnostics.Debugger class, LINQPad also provides a great entry point for debugging plugin logic and helper classes. This has been saving me time by minimizing the test/update/build/re-register/repeat cycle.

Note that in this case I am not listening in to network traffic—it’s not capturing plugins that are fired on the server. Instead, I’m directly testing the code used inside of derived classes’ IPlugin.Execute method.


Here is how I set it up. First, reference the plugin DLL from LINQPad and add the appropriate namespace(s).



In your LINQPad program, set up any test data you need in order to run your logic. Add the line Debugger.Launch() before the code you want to debug. You can also add Debugger.Break(), which is useful if you want to set breakpoints within your LINQPad program (in Visual Studio, you set your breakpoints as you normally would). Next, run your program. If a debugger isn’t running already, it will catch on the Launch() method and open up the debugger dialog. Note that LINQPad will crash if you cancel out of the dialog.


Now you are stepping through your LINQPad program and plugin logic in the Visual Studio debugger! Find defects, update, rebuild and test as necessary. Don’t forget to re-register your updated plugin assembly when you’re done.


For more information on using LINQPad with CRM, check out our previous blog post on Testing CRM Queries with LINQPad.

CRM 2013 UR 1 is Available!

Update:  The download link is now available and working!

Microsoft has released UR 1 for some CRM 2013 Online organizations and has provided a KB article for on-premise here.  The download for UR 1 doesn’t appear to be working just quite yet but the KB article has provided insight into the fixes that have been made.  It appears that several key issues were resolved including some issues with the API not working correctly.  Below we have highlighted some of the key issues.  Head here for a full list.

General Issues:

  • Invalid Argument when navigating to view with related entity lookup.
  • Script error occurs when moving from a form. "Unable to get property 'get_filterType' of undefined or null reference"
  • Users cannot associate multiple records at once for N:N relationships.
  • When data is entered into a form, the Save button can be clicked multiple times which results in multiple of the same record being created.
  • Autosave off: Entity form looses command bar after navigating away and re-opening.
  • When browsing to various locations in CRM, a JavaScript exception is thrown that reports "Object expected".
  • Opportunity closed as won does not take custom status reason while closing.

API Fixes:

  • Disabling checkbox fields using the JavaScript API does not work.
  • Unable to set a web resource to visible in script if 'Visible by default' not set in designer.
  • For a custom duration field Xrm.Page.getAttribute("durationfield").getValue() method returns a formatted value like 30 minutes instead of 30 as expected.
  • The .addCustomFilter javascript function does not work properly.

To check if UR 1 has been applied to your Online org, click the gear icon at the top right and select ‘About’


Towards the top of the About dialog displays the version number.  If it starts with 6.0.1 versus 6.0.0 then your Online organization has UR 1 applied.  The third number here being the number of the UR applied.


Manipulating Composite Fields in Dynamics CRM 2013

A great new feature in Microsoft Dynamics CRM 2013 are the Composite Controls.  This blog goes into detail about these new controls.

With this new control comes many questions about how configurable the controls are.  As of right now, they’re not configurable.  All you can do is add/remove the composite control from the form using native customizations.  For example, the address1_composite field is the composite control for address 1 on the Account form.  This shows up at as “Address1” in the Field Explorer when on the Account form.



However, at the CRMUG Midwest (Chicago) Regional Chapter Meeting this past Thursday 12/5, we found out about a neat trick using another new Dynamics 2013 feature - Business Rules (thanks Richard Knudson!).  You can use Business Rules to show and hide fields on the form, which also has the positive side effect where this applies to fields in the Composite Controls.  So, at the very least, you can hide fields that aren’t needed in certain countries or regions of the world, and show them in others.

An example would be to show/hide parts of the address that don’t pertain to certain countries.  For simplicity sake, we’ll hide the Address Line 3 field if the country isn’t “U.S.” and show it otherwise.  In order to do this, we create two Business Rules on the Account entity as outlined below.



Now let’s see this in action.  If you set the Country to “U.S.”, you’ll see Address Line 3 in the Composite Control, and if it’s any other value, it’ll disappear.



The same sort of trick applies also to setting the requirement setting for fields.  If you use Business Rules, the rules you build won’t only apply to fields on the form, but also to fields in Composite Controls.

While this is a great neat trick, a big request that we have is to be able to add a custom lookup field for Country and even State.  This way administrators can control the data that’s entered and prevent allowing any data in a free form text field.  You can do this with CRM currently, but you can only add it to the form.  You cannot add this new lookup field to the Composite Controls.  We’ve logged this Microsoft Connect request and hopefully in future releases / Update Rollups we’ll se more configurability added to this great new Composite Control feature. 

However, you can use the Business Rule trick above, along with new lookup fields, if you also have some logic that populates the native text fields based on the selection of your custom lookup fields.  You can also then make the native text fields read only, so it looks to the end user like you’re displaying the custom lookup field in the composite control.  This is a workaround that isn’t too difficult while hopefully Microsoft makes this more configurable using the form designer in the near future.

Topics: Microsoft Dynamics CRM Microsoft Dynamics CRM 2013

Creating a CRM 2011 Form Save Experience in CRM 2013

Recently we ran into an issue where entity forms will still automatically save when the form is closed and auto save is disabled through the System Settings.  With auto save turned on, it makes sense that the form would automatically save when the user navigates away but since we disabled auto save, it caught us off-guard that the form was still saving.  This means that even with auto save disabled, the user has no way to easily cancel their changes as closing out the form will just end up saving the changes.

In CRM 2011, the user would use the “Save and Close” ribbon button to save their changes before navigating away and alternatively just close the form if they didn’t want to save their changes.  With CRM 2013, the “Save and Close” button is gone and now any action taken that navigates away from the form (closing the window, back button, clicking “Pop Out”, etc) will act as a “Save and Close”.  With this information, we can write some simple JavaScript to prevent saving when the user navigates away from the form. 

Below is a function to be registered in the OnSave event of the form.  This function will get the save mode of the execution context and check for the value 2 which is the “Save and Close” event mode.  Then it will simply cancel the save operation by calling preventDefault() on the event args.

function preventSaveAndClose(context) {
    var args = context.getEventArgs();
    if (args.getSaveMode() == 2) {

Be sure to check the “Pass execution context as first parameter” option in order for the save mode to get passed into the custom function.


Now when navigating away from a form with unsaved changes, instead of automatically saving, the user will be presented with a similar CRM 2011 warning explaining that changes will be lost if continued.


A combination of the above custom JavaScript function and disabling auto save in the System Settings should help provide similar form functionality that users are familiar with from CRM 2011.