CRM Solution Manager keeps getting better

Full disclosure, I received a free license from the authors of the tool.  However, I do believe it’s definitely worth the license fee.

I’ve blogged previously about reasons for my fondness of the www.crmsolutionmanager.com addin to Visual Studio for Dynamics CRM 2011 development.  Well they’ve recently introduced some new features that I think make it an even more compelling alternative to the Developer Toolkit for Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online.

@devkeydet

Make sure your CRM 2011 customizations will work with the upcoming cross browser release

UPDATE: The Dynamics CRM in the Field blog just published a useful post on Script Errors after Installing UR12.

The next update to CRM 2011 introduces an expanded range of supported browsers.  You can learn more about the upcoming release here:

http://crm.dynamics.com/en-us/Polaris

http://crmpublish.blob.core.windows.net/docs/Release_Preview_Guide_December_2012_FINAL.pdf

Ahead of the release, the latest version of the CRM SDK has guidance on ensuring the JavaScript code you write works in the supported browsers:

http://msdn.microsoft.com/en-us/library/hh771584.aspx#BKMK_WriteJavaScriptForMutlipleBrowsers

The SDK also links to a blog post by the CRM team covering a tool to help existing customers identify where they might have cross browser compatibility issues in their existing web resources:

http://blogs.msdn.com/b/crm/archive/2012/06/21/microsoft-dynamics-crm-2011-custom-code-validation-tool-released.aspx

This tool is not guaranteed to find every cross browser compatibility issue.  As the blog post says, it is also possible for the tool to identify false positives.  Therefore, I would recommend that anyone planning on deploying this update test it in a non production environment first before applying it in production.

The good news is that if you have already followed the guidance in the CRM 2011 SDK regarding what’s supported in terms of customizations using web resources, then your customizations should continue to work after applying the update once it is released.  The CRM team has already done the work to validate that going through supported APIs works with the update.  The bad news is that sometimes people implement unsupported customizations, without understanding that what they’ve done is not supported.  Often times, they find a way to do something on a blog.  However, the blogger doesn’t make it clear that while the approach “works” it isn’t supported.  The resources above will help you identify and fix those kinds of issues in your code.  Please read these resources carefully, understand the potential impact to your customizations, and test appropriately.

I want to reiterate that the supplied resources will not guarantee you haven’t missed something.  They are not a replacement for testing.  They simply make it easier to identify and fix issues before you test.  Hence reducing the issues you find during testing.

@devkeydet

Improving the performance of multiple Inserts, Updates, and Deletes via the CRM 2011 Organization Service

UPDATE: Now that Polaris/UR12 are out, the new bulk API is available.  Check out Sonoma Partners blog post on a simple benchmark of the improvements.  Now you can Combine the ne bulk API with client side parallelism to achieve even better performance.  I’ll put that on my ever growing “to blog” list.  However, if you followed this post, then you should be able to figure it out yourself. 

UPDATE: Removed explicitly creating a ConnectionStringSettings object by calling CrmConnection.Parse().

If you are writing any .NET code that interacts with the Organization Service, any insert/update/delete performed happens one at a time, even if you call OrganizationServiceContext.SaveChanges().  This is a perfect candidate to improve performance using the Task Parallel Library.  Here’s a little code snippet to get you started:

var conn = CrmConnection.Parse("Url=https://YOURORG.crm.dynamics.com;Username=YOURUSERNAME;Password=YOURPASSWORD");
var ctx = new MyDataContext(new OrganizationService(conn));
 
var query = from a in ctx.AccountSet
            select new Account
            {                
                Id = a.Id,
                Name = a.Name,
                Address1_City = a.Address1_City
            };
 
var tasks = new List<System.Threading.Tasks.Task>();
var accounts = query.ToList();
 
foreach (var account in accounts)
{    
    // Parallelize each update until BulkAPI is released in UR12
    var task = System.Threading.Tasks.Task.Factory.StartNew(()=>{        
        ctx.Detach(account);
 
        account.Name += " - UPDATED";                
        account.Address1_City += " - UPDATED";    
 
        var newctx = new MyDataContext(new OrganizationService(conn));        
        newctx.Attach(account);
        newctx.UpdateObject(account);        
        newctx.SaveChanges();
    });
}
 
//Wait for all the updates executing in parallel to complete.
System.Threading.Tasks.Task.WaitAll(tasks.ToArray());

On my quad core laptop.  The serial version of this code takes a little over 5 seconds.   In comparison, the code above executes in less than a second.

@devkeydet

LINQPad, CRM 2011, and using Office 365 accounts

I recently discovered that the LINQPad Plugin for Microsoft Dynamics CRM 2011 doesn’t support authenticating using Office 365 credentials.  According to commenter EdWells, you can copy the latest version of crmsvcutil.exe and microsoft.xrm.sdk.dll over the version that ships with the LINQPad plugin as a workaround.  However, this didn’t work for meSad smile.  Have no fear, LINQPad allows you to reference external dlls.  So I just manually ran crmsvcutil.exe, compiled the output into an assembly using Visual Studio, and then referenced the dll + appropriate dependent assemblies.

clip_image002

You add References/Imports via the properties dialog:

clip_image004

MsftIanImportTest.dll is the assembly I put the crmsvcutil.exe code in.

clip_image006

Here’s a basic example to get it all wired up:

clip_image008

UPDATE: I use LINQPad as a way to do things like update multiple records, etc.  I have a tip to improve execution time performance here.

@devkeydet

Getting started with the CRM 2011 Windows Store app sample

UPDATE (18APR2013): Updated AuthenticateAsync() extension method to handle both IFD and CRM Online authentication.  Now, the code in HelloCRM will work regardless of whether you point it to an IFD or CRM Online Organization Service.  All you have to do is pass in the appropriate username/password combo to AuthenticateAsync().  Quick link to updated code: http://sdrv.ms/Qy0Wcv.

UPDATE (12MAR2013): Found another issue with my helper extension methods around when I was detaching the event handler.  Uploaded a zip file with the improved helper methods.

UPDATE: There was a bug in my extension methods.  I wasn’t detaching the event handlers after the event had been handled.  This caused issues with subsequent calls to the Async extensions methods.  I’ve fixed the code to detach the event handlers appropriately.

I’ve blogged about a hackish, but workable approach to building an Windows Store app here and here.  However, as I mentioned in the post, if you like it use it.  If not wait until there’s an official SDK sample.  Well, in early November, the CRM time published the official SDK sample:

http://blogs.msdn.com/b/crm/archive/2012/11/02/building-clients-for-windows-phone-and-windows-8-rt.aspx

The feedback I’ve gotten from a few folks who’ve looked at the official sample is:

  • “It’s not exactly the easiest sample to follow.  Can you give me a hello world example?”
  • “I can’t use crmsvcutil.exe generated code with the sample.”
  • “I have to use Event-based Asynchronous Pattern (EAP)?  It’s Windows 8!  Everyone expects async / await capable APIs.”

The goal of this post is to address these common responses with:

  • A simplified hello world example to get you started
  • How to use crmsvcutil.exe generated entities so you have early bound / strongly typed / data binding friendly classes
  • Starter extension method examples which wrap the EAP nature of the sample API and give you async / await friendly methods

 

 

You can grab the hello world example from the video here:

http://sdrv.ms/Qy0Wcv

In the video, I make reference to Erik Pool’s wonderful tool to control what gets generated from crmsvcutil.exe:

http://erikpool.blogspot.com/2011/03/filtering-generated-entities-with.html

The inspiration for the Extension methods comes from this Stack Overflow post:

http://stackoverflow.com/questions/12853445/convert-event-based-pattern-to-async-ctp-pattern

I blogged about using LINQPad to create FetchXml here:

http://blogs.msdn.com/b/devkeydet/archive/2012/04/22/getting-fetchxml-from-linqpad.aspx

@devkeydet

The BEST SiteMap editor you probably don’t know about

One of the keys to being a more productive CRM developer is knowing what community tools are out there.  Sometimes, as soon as you think you have a favorite tool, you find another one that makes you smile.  Hopefully, I’m helping create one of those moments for you.  I’ve blogged about CRM Solution Manager before.  CRM Solution Manager comes with what I think is THE BEST SiteMap editor I’ve come across.  It’s a VISUAL editor in the spirit of Visual Ribbon Editor and Ribbon Workbench

image

What you probably don’t know is that while you get this editor when you purchase CRM Solution Manager, the author makes the SiteMap tool available for FREE.  Yep, that’s right.  No strings attached.  Just go to the downloads page and you will find it hiding in plain sight! 

image

What are you waiting for?  Go get it!

@devkeydet

The ultimate documentation tool for Dynamics CRM 2011

SnapShot! for Dynamics CRM – http://www.crmaccelerators.net/products/snapshot-for-dynamics-crm

…extracts and consolidates the following components:

  • System Settings
  • Entities
  • Fields
  • Relationships
  • Views
  • Forms
  • Option Sets
  • Field Security
  • Security Roles
  • Solutions
  • Web Resources
  • Plugins
  • Processes
  • Templates
  • Business units
  • Users
  • Teams
  • Queues

I’ve had customers ask for something like this many times!  Good to know I have an answer for them now!

@devkeydet

Developing CRM 2011 customizations without a local server

I’ve spent a lot of time over the last year applying my general application development experience to the world of Dynamics CRM customizations (aka XRM).  Often, I take part in conversations that go something like “Why is X harder to do when customizing Dynamics CRM compared to general .NET web development?”  I usually respond with “Well how exactly are you doing X?”  After finding out, my next response is usually along the lines of “Well have you thought about doing it like Y instead?  That’s a much more productive way.”  The next response is usually “Well, why isn’t that documented somewhere?”  My answer is usually “Well, it’s really just applying proven development practices to CRM.”  These conversations are usually the catalyst for many of my blog posts.  Sorry for the contextual tangent.  Back to the point of this post.

When I first started focusing on Dynamics CRM about a year ago, I was adamant about developing in an isolated VM which included the CRM Server installed (if at all possible).  The main reasons were:

  • Developing in isolation from others
  • Ability to attach to the necessary processes to debug plugins and workflow activities
  • Speed of deploying web resources / plugins to the server through the developer toolkit (no network latency slowing the process down)
  • Ability to create/delete CRM organizations on the fly for prototyping, starting from a clean environment, etc.

I still believe this is the best setup for CRM developers.  However, I also recognize that many folks don’t have the hardware resources to give each of their developers a machine that can handle such an environment. 

I’ve been asked quite a few times “Why isn’t there a lightweight dev server for CRM like there is for ASP.NET?”  That’s a much longer discussion.  It’s the same basic answer as why SharePoint and other server products with APIs don’t have one.  However, what I think people really want is to be productive developing without having to install the full fledged server locally.  As I was building out the walkthroughs for my posts on unit testing:

… I had a bit of “DUH” or “AHA” moment.  If you practice Test Driven Development (TDD) using these approaches, go with the one org per developer approach on a remote server, and sprinkle in effective team development approaches enabled through Solution Packager, then you can become quite productive developing without a local server.  Your remote server becomes your integration testing environment. 

I still prefer doing all of the above in a local, isolated VM environment.  There’s nobody else playing in my sandboxSmile.  However, when you don’t have the luxury of installing CRM locally, I’ve learned that the combination of these approaches against a remote server can be a surprisingly productive setup.  I’ve been forcing myself to use this approach lately, even in a local VM.  It does take some getting used to.  I call this the “up front setup/config tax.”  Once you’ve paid the tax and get into a rhythm doing things this way, I think you will appreciate the efficiencies gained.  Try it out.  Let me know your thoughts.

@devkeydet

Unit testing CRM 2011 JavaScript web resources

UPDATE: Fixed the video resolution issue.  Higher resolution (720p) version is available.

After writing my post on unit testing plugins, I’ve been asked a few times about how to do the same for Dynamics CRM 2011 JavaScript web resources.  While I knew it could be done, truth be told, I had never done any significant JavaScript unit test using Visual Studio other than unit testing Script# code using MSTest (the default unit testing framework in Visual Studio).  Sure, I had played around with QUnit.  However, QUnit is one of those JavaScript testing frameworks which requires tests to run within a browser.  What I wanted was an approach which met the following criteria:

  • Integrate with MSTest so:
    • I have one test dashboard for both my plugin & JavaScript unit tests
    • I get as much of the TFS integration goodness I can get
      • Gated check-ins
      • Running tests on a build server
      • Etc.
  • Write and debug my code without having to constantly deploy to a CRM server to test and iterate on my code
  • Mock things like Xrm.Page, web service calls, interaction with the HTML DOM, etc.
  • Integrate with the Developer Toolkit
  • Run tests OUTSIDE of the context of a browser

So I scoured the internet, tried a bunch of things I came across, and finally landed on approach which combines lessons learned from the following resources:

While the catalyst for this video was to demonstrate JavaScript unit testing in the context of Dynamics CRM 2011, the approach can be applied to any scenario where you are using JavaScript and some additional API (SharePoint, standard web app, etc.).

Just like with my post on unit testing plugins, it is not my goal here to convince you that you should embrace unit testing.  It’s for those of you who have already bought into the value of unit testing, want to apply it to JavaScript web resource development, and do it in a way that meets my stated criteria above.  In the video, I assume you understand concepts like mocks, fakes, etc. 

You can grab the finished example I show in the walkthrough here:

http://sdrv.ms/StxcgU

Hope this helps those of you who have been as eager as I have to unit test JavaScript web resources.

@devkeydet

WEBCAST: CRM 2011 Team Development With Shan McArthur

UPDATE: If you missed the webcast, you can watch the recording via the details link below.

Team development for Dynamics CRM 2011 customizations is a topic I get into often with customers and partners.  The best, most comprehensive session I have seen on team development with Dynamics CRM 2011 was delivered by Shan McArthur (blog, twitter) at eXtreme CRM (Las Vegas) this year.  My biggest frustration about his session was that only the people at eXtreme CRM could benefit from knowledge he was sharing.  Good news!  Shan’s delivering an updated and extended (2 hour) session on this topic for the XRM Virtual User Group on 11/29/2012 (sorry for the short notice).  Details here:

http://www.xrmvirtual.com/events/team_dev_ShanMc_CRM2011

This is a MUST SEE webcast in my opinion.  Watching it just may improve your life as a Dynamics CRM developer.

NOTE: The “Register for Event” button will be disabled unless you are signed in to the site.  Have no fear, there is also a “Attend Live Meeting Here” link on the page in the event you are undecided about becoming a member.  If you aren’t a member, you should be (it’s free). 

@devkeydet