Tag Archives: CRM

Updated Developer Tips and Tricks Deck

I spend a lot of time talking to .NET developers who are looking at building business applications using Dynamics CRM.  They journey to understanding how to be a productive Dynamics CRM developer can sometimes be daunting.  There’s a bit to learn on top of your existing .NET / web dev skills.  If you go through any CRM developer training, including the Dynamics CRM 2011 Developer Training Kit, you usually won’t get to the level of productivity building solutions that a seasoned CRM developer has.  My Developer Tips and Tricks deck is aimed at helping people get there faster.  I just spent a good part of the day updating the deck.  It’s a living document where I modify as I learn new things.

@devkeydet

Moving an existing Hyper-V vhd to Windows Azure

I talked about building a CRM dev VM running on Windows Azure from scratch here.  However, you might have an existing VM that you’d prefer to run on Windows Azure instead.  Why?  Here are some reasons I can think of which may or may not apply to you:

  • You can take advantage of better hardware.
    • Even though I have a quad core 16 GB laptop, everything just feels like it runs faster in the Windows Azure VM.  Placebo effect?  Maybe.
  • You can access your dev box from just about anywhere with a Windows PC and an internet connection.
  • Windows Azure has better bandwidth than you might have.
    • Run a speed test to compare…make sure you pick a test server closest to your Azure data center for accurate comparison

I am sure there are others.  Feel free to share in the comments.  To get started, you are going to have to upload your .vhd file to your Windows Azure Storage account.  To do this follow the instructions starting at Step 5 from the Creating and Uploading a Virtual Hard Disk that Contains the Windows Server Operating System right until the Upload the VHD file section.  Use the following command line switches for csupload instead (make you have the June 2012 Azure SDK):

csupload Add-Disk –Destination “<full blob url you want for your vhd>” –Label “<whatever you want>” –LiteralPath “<path to your local .vhd>” –OS Windows

After the upload completes, you should be able to go into the management portal, create a new VM using this vhd file.

@devkeydet

CRM Solution Manager

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 been using the CRM Solution Manager add in for Visual Studio quite a bit lately.  I’ve grown fond of using it over the Developer Toolkit for web resource development.  The biggest reason is because I can right click a set of web resources, deploy AND publish in one click:

image

Another nice feature is that it translates folder structures into web resource names that follow the relative url naming recommendations here:

image

image

One more web resource feature that’s nice is that it allows you to configure JavaScript and CSS minification during the deploy/publish process:

image

I uncheck these during development so I can debug the code, but it’s a nice way to get everything minified for your production release.  While I still find the Developer Toolkit useful for plugins and workflow activities, the CRM Solution Manager has become my tool of choice for web resource development.  It also has other nice features that I haven’t dug into yet.  Check it out! 

@devkeydet

Building an entity model faster through the CRM 2011 import process

Here’s a little tip that, as I speak with customers/partners, I’m discovering isn’t well known.  I will show you how to leverage features of the import process to the fact that import process allows you to build your entities much faster in Dynamic CRM 2011.  It is one approach, but I would love to hear any you might have.  The basic process is:

  • Create entity
  • Create option set fields
  • Create relationships where necessary
  • Import data and create the rest of the fields along the way

To get this to work without prefix side effects, make sure you follow the instructions in my Ensuring you are using your prefix everywhere post first.  Let’s start with a very simple entity model:

 

image

I know, bad example, but I wasn’t feeling creative.  To build this out we’re first going to create the Parent and Child entities:

image

image

NOTE: As a personal practice, I always clear out everything below the Options for Entity section of the form.  You can always go back and add features later, but you can’t undo things that have the + sign next to them. 

Technically, we could create the entity as part of the import process, but I prefer creating it explicitly because I have full control of the creation options.  For Fields of type Option Set, you should create them in the entity ahead of time.  In this example we are going to create a Blood Type field and create a new reusable option set with the values in the picture: 

image

image

Technically, you can create option set fields during the import process, but they won’t be reusable.  Therefore I always create them ahead of time.   For other field types, we’ll create them during import.  Now, let’s go ahead and create a 1:N relationship between the Parent and Child entity:

image

image

Technically, we could create the relationship during import, but I prefer creating it explicitly because I have full control of the options.  Next, create two csv files that look like:

 

Parent.csv

Name,Date Of Birth,Blood Type

Parent1,11/05/2000,O+

Parent2,11/05/2000,A+

Parent3,11/05/2000,B-

 

Child.csv

Name,Date Of Birth,Blood Type,Parent

Kid1,11/05/2000,O+,Parent1

Kid2,11/05/2000,A+,Parent2

Kid3,11/05/2000,B-,Parent3

 

 

Now import Parent.csv:

image

Browse to the file and accept the defaults until you get to this screen:

image

As you can see Blood Type is already mapped to the option set we created.  Map the Date Of Birth field:

image

Keep clicking the Next button until you get to the end and click the Submit button.  The Import Data Wizard will create the remaining field and import the data.  Now let’s get the Child entity set for import.  Go ahead and create the Blood Type option set field for the Child entity like we did for the Parent, but this time reuse the existing option set.  Now import the Child.csv file.  You will have to create a new field for Date Of Birth, but Blood Type and Parent from the input file will have been auto mapped to the corresponding fields in the entity:

image

That’s it!  I’ve shown a really simple example where we really only automated the creation of one field per entity.  I did that to keep the walkthrough simple.  I also walked through why I choose to still manually create option set fields and relationships.  If you apply this technique to creating entities with say 10+ fields, you really start to appreciate the productivity gains of automating the field creation process.  HTH

@devkeydet

Ensuring you are using your prefix everywhere

With Dynamics CRM 2011, there are many ways to get the same task done when you are customizing your solution.  However, what prefix is used depends on where you came from.  Let’s take the scenario of creating an entity.  If you are working in the Default Solution, then you probably have a prefix of new_ unless you have already changed the prefix of the Default Publisher:

image

image

If you are working in a solution you’ve created, but using the Default Publisher, then you probably still have a new_ prefix.  If you are working in a solution you’ve created, using a publisher you’ve created, and created the new entity in from within that solution, then you will have the prefix of the publisher you created:

image

image

However, when you customize anything through the Customize tab in the ribbon:

image

…you will be brought to the Default Solution, which means your prefix will be whatever is in the Default Publisher.  To get your prefix to show up when you use the Customize tab, you need to update the prefix of the Default publisher to match the prefix of your publisher:

image

image

By doing so, your prefix will be the default everywhere you try to customize the system.

@devkeydet

Upgrading to IE9 without breaking incompatible apps

As many of you know, the CRM 2011 UI leverages more “in browser” processing.  Because of this, CRM 2011 will perform better when using the latest version of Internet Explorer (currently IE9) because of IE’s advances in performance through hardware acceleration.  Simply put, CRM 2011 runs best on IE9.  In speaking with many customers about this topic, I typically get the following response:

“We can’t upgrade to IE9 because we have apps that only work in IE7/8. We can’t afford to invest in updating those applications just so we can run CRM on IE9.”

There’s a solution. The reality is that you CAN tell IE9 to render your app in IE7/8 compatibility WITHOUT changing your web app code. Unfortunately, I’ve found that most people just don’t realize it is possible.  The Defining Document Compatibility article explains how to make it so that IE9 will render as if it were a previous version IE.  What most people overlook is that you can do this without modifying a single line of your applications code.  How?  Jump to the Configuring Web Servers to Specify Default Compatibility Modes section of the previous link.  It explains how.  Hopefully this helps in making the decision to upgrade the workstations in your environment to IE9 so that you can take advantage of it’s advances in performance, etc. without breaking your incompatible web apps.

@devkeydet

Building a CRM 2011 dev box using a Windows Azure Virtual Machine

UPDATE: The instructions were a bit out of order.  Thanks for @DynamicsCRM_EDU for the heads up!  I fixed it.  Please let me know if you find anything else that needs clarification.  I write these things late in the night most of the timeWinking smile.

I am a big fan of the One Organization per Developer approach to team development with Dynamics CRM 2011.  Additionally, I think every CRM developer should have their own isolated development environment (just like most traditional development environments).  Some of the benefits:

  • Not stepping on other peoples work (or worse someone else hosing my work)
  • No one else’s publishing action slowing me down
  • Can attach debuggers for plugin / workflow activity code
  • Sometimes you need to spin up/tear down CRM orgs for prototyping, fixing things that are hard to undo once you’ve done them, etc.
  • Like most development, you churn a bit until you are ready to check your changes in for others to use

I’ll be blogging more about source control stuff, but have a look at this post for a peek at a tool that’s coming to make source control of non code customizations easier:

http://dkdt.me/LuupSo

Frankly, the problem with building out a CRM dev box is that it requires capable hardware to run CRM and Visual Studio and SharePoint and SQL and Reporting Services and…you get the point.  Sometimes, acquiring capable hardware is not something you have control over Sad smile.  Therefore, people end up using less than adequate developer environments for CRM development.  While CRM Online is great for production and staging environments, it just doesn’t offer the developer productivity that self contained, all tools on one box, isolated CRM environment do.  Windows Azure’s new Infrastructure as a Service (IAAS) Virtual Machines (VMs) to the rescue!  I just wrapped up building my first CRM dev box on Windows Azure.  Here are my notes on getting it working for those who want to try it.

DISCLAIMER: CRM 2011 isn’t support for production deployment in Windows Azure VMs just yet, but works just fine in a single VM developer install.

First, I followed the instructions below up to the Open the virtual machine using Remote Desktop and complete setup section.

http://dkdt.me/NTRiPa

I chose a 4 core, 7 GB RAM VM because that’s what I run for the VM on my Lenovo 510 laptop.  You can probably get away with less, but this config has served me well OnPremises, so I went with it.  Once I was able to establish a Remote Desktop connection, I immediately went into Server Manger and clicked the Configure IE ESC link and turned it off so I could surf the web without warnings:

image

Then, I enabled Microsoft Update:

http://dkdt.me/LuusgN

I went ahead and ran Microsoft Update and installed everything. 

https://www.windowsazure.com/en-us/manage/windows/how-to-guides/attach-a-disk/

The Windows Azure VM we picked has two drives (C: and D:).  The C: drive only has 30 GB.  The D: drive isn’t durable, so don’t put anything on it that you expect to still be there if your VM gets rebooted, moved, etc.  Therefore, you are going to want to add another drive for your databases.  I added a 30 GB drive:

image

image

You will also need to initialize the disk in the VM:

http://dkdt.me/MlAOOH

Make sure you configure SQL Server to use the new drive as the default location for data and log files:

http://dkdt.me/LuupSp

Per this blog post:

http://dkdt.me/LuusgO

…you don’t want write caching on the disk your databases are on.  The good news is that the data disk we just created has write caching off by default.  The pre-configured VM I picked from Windows Azure already has SQL Server 2012 installed, including Reporting Services.  From there, I followed the instructions in Girish’s  blog to setup a CRM 2011 VM:

http://dkdt.me/LuupSr

Of course, you can skip the Windows/SQL Server/Hyper-V stuff since we already have a VM running in Windows Azure with Windows/SQL pre-installed.  You can skip to about the 19:30 point in the video to get started.  At about the 23:00 point, you’ll need to reboot.  The next step in the video is to install SQL Server.  While you don’t need to because it’s already installed in the VM, you do need to configure Reporting Services (accept all defaults, unless I call a change out otherwise):

image

image

In the picture above, make sure you run under a domain account.  Otherwise, the CRM Reporting Extensions will not pass the environment check.

image

image

image

    

Since we don’t need to install SQL Server, you can skip to the 34:15 point.  At about the 38:10 point, you will be told to go ahead and Run the SharePoint Products Configuration Wizard.  DON’T!  Instead, install Service Pack 1 for SharePoint Foundation:

http://dkdt.me/LuusgP

Once you’ve done that, then pick up where the video left off by manually running the SharePoint Products Configuration Wizard:

image

When you get to the point of running the CRM 2011 installer, grab the bits from:

http://dkdt.me/Luuq8E

This update has Update Rollup 6 slipstreamed so it installs perfectly fine on SQL Server 2012.  You can use your MSDN/TechNet keys to register CRM 2011 if you want to use the VM for longer than 90 days.  Otherwise, just use the trial key from the link above.  The last thing I did was run Microsoft Update one more time and accept all the updates (which include Update Rollup 8).  Cleaning up any of the installer files you downloaded isn’t a bad idea either.

At this point, you have a fully functional CRM 2011 dev box which you can remote into and work within in isolation.  Of course, you’ll probably want to have a look at My CRM Dev VM post which talks about what else I like to install into a CRM Dev VM.  If you need source control for this VM, then you should try http://dkdt.me/Luuq8G.  If you really need to gain access to resources from the VM that are behind your corporate firewall (like an existing TFS server), there’s always Windows Azure Virtual Network

Hopefully this helps any of you out there who had the same idea I had!

@devkeydet

UPDATED SAMPLE: CRM 2011 Metro style OData helper

I’ve updated the sample I started here by implementing Create Update and Delete methods.  The library is still not complete or well tested, but it is at least a head start to building a CRUD capable Windows 8 Metro style application using the CRM 2011 OData (aka Organization Data) service.  Both the helper web resource and the Windows 8 Metro style source code have been updated.  The Visual Studio solution now has a little sample Metro style app to quickly test out the functionality of the library.

http://sdrv.ms/NIiMY2

To get the sample to work, you will need to import the updated CRM solution package which updates the helper web resource. Also, make sure you change the CRM organization url in the sample app.  You can still follow the instructions from the first post since there are no breaking changes in the sample, just new functionality.

@devkeydet

CRM 2011, OData and datajs

UPDATE: FALSE ALARM about batch updates.  Turns out the CRM 2011 OData service doesn’t support batch updatesSad smile.  I just assumed it did because I’ve written .NET/Silverlight clients against the CRM 2011 OData service using a derived DataServiceContext.  DataServiceContext based contexts using the “unit of work” pattern through SaveChanges()/BeginSaveChangesc() and they’ve always “just worked.”  I just confirmed that Batch isn’t the default SaveChangesOption so all this was predicated on a bad assumption on my partSad smile.  Nothing to see here.

What people often call the CRM 2011 REST Service or Organization Data Service is an OData service.  If you go to the libraries section of the OData site and select JavaScript, you will be linked to the datajs CodePlex site.  So what about the CRM SDK OData samples (SDK.REST.js and SDK.JQuery.js)?  It’s probably one of those “six in one hand, half dozen in the other” situations in terms of the shared capabilities of the libraries.  Which API you like better probably boils down to a style preference.  There are some differences in capabilities as well.  The CRM SDK libraries have explicit functions to associate / disassociate records.  One of the things the CRM SDK sample libraries don’t offer is a facility to do batch updates, but datajs does.  This comes in really handy when you want to do a bunch of work client side to some data and send it all at once.  Have a look at the OData Code Snippets.  They also have a full OData API reference.

@devkeydet

Adxstudio Productivity Pack

http://dkdt.me/LozNSi

Run, don’t walk, and go grab this CRM dev essential.  A few of my blog posts are irrelevant (or at least much less effort) once you’ve installed this free set of enhancements to Dynamics CRM 2011.  From their website:

Adxstudio Productivity Pack is a suite of customizations for Microsoft Dynamics CRM® 2011, useful across a wide rage of CRM applications. It includes the following enhancements:

  • Rich Text Editor (TinyMCE)
  • Auto Numbering
  • Bing Maps Geolocation Lookup
  • Date/Time Parsing
  • Boolean Parsing
  • General Application Settings

This product is provided to the Adxstudio community at no cost.

@devkeydet