If you haven’t heard, CRM Online has completed the Polaris rollout and UR12 is available. With it comes a new bulk API which makes programmatic data import into Dynamics CRM 2011 faster. Check out Sonoma Partners blog post on a simple benchmark of the improvements. As you can see, it’s really worth moving to this new API. What? You don’t do data migration in code:)? You use a third party tool like the CozyRoc and KingswaySoft SSIS adapters or Scribe? The good news is that both CozyRoc and KingswaySoft have already updated their adapters to support this new API. I’ve also updated my Improving the performance of multiple Inserts, Updates, and Deletes via the CRM 2011 Organization Service post to suggest how one can combine bulk with parallelism to achieve even better performance. In fact, if you review my Data Migration with CRM 2011 post, you’ll recognize that the Balanced Data Distributor (BDD) is an addon to SQL SSIS which enables parallelism within your SSIS package.
CRM, Accessibility, and 508
I’ve spent many a time having accessibility and 508 compliance discussions with customers and partners over the years working at Microsoft and focusing on various web based technologies. In fact, it’s hard to believe I recorded this video over seven years ago:
https://channel9.msdn.com/Blogs/keydet/Creating-an-Accessible-Web-Page
As it relates to Dynamics CRM 2011, whether your overall implementation is accessible is a combination of:
- Whether the HTML the CRM product produces is accessible
- Whether your web resources are accessible
- Whether any custom ASP.NET, etc. pages integrated into the CRM UI (say through iFrames) are accessible
For #1, the CRM product team produces a document called a Voluntary Product Accessibility Template (VPAT). Ben does a good job explaining the relationship to 508 compliance and VPATs here so I won’t go into it. As Ben mentions, all of Microsoft’s VPATs are available at:
http://www.microsoft.com/government/en-us/products/section508/Pages/default.aspx
The most recent VPAT for Dynamics CRM 2011 (as of writing this) is: Microsoft Dynamics CRM December 2012 Service Update VPAT. For #2, the CRM 2011 SDK has a section called Create Accessible Web Resources to help you. This section is chock full of resources and links to external resources on accessibility. What surprised me is that it doesn’t talk about Visual Studio’s built in accessibility checker which is covered in Visual Studio’s Accessibility in Visual Studio and ASP.NET documentation. For #3, you need to similarly understand how to make sure those pages are accessible. Visual Studio’s ASP.NET Controls and Accessibility should prove helpful. In fact, the 7+ year old video I recorded that I link to earlier shows both the accessibility checker and general ASP.NET accessibility techniques in action. Hopefully this post is helpful to those of you who are going to be in the business of ensuring your CRM implementation is accessible. Here are a few other resources you will want to review which are not linked from the other resources in this post as far as I can tell:
Now that the latest CRM Online update is complete and UR12 is out, Dynamics CRM 2011 is now cross browser capable. Therefore, you can now use the popular WAVE Toolbar Firefox addon to check accessibility of your customizations. Yea, I know, a Microsoft guy recommending Firefox. I don’t know of a better free tool that allows you to check accessibility of web pages without uploading html or point the tools servers at your web site. The latter kind of validator won’t work for CRM deployments because of authentication. Plus, you should be testing all your customizations in Firefox and Chrome anyway.
CRM Online & Windows Azure Series
I’ve been working with a few CRM Online customers on some advanced scenarios which require using Windows Azure as part of their overall solution. As a result, I will be publishing series of blog posts and samples which walk you through the following:
- Configuring Single Sign On (SSO)
- Improving the SSO experience
- Calling CRM from ASP.NET using impersonation to ActOnBehalfOf the logged in user
- Authenticating to an Azure hosted web service from CRM Online Sandbox code
- Integrating with systems behind a firewall from CRM Online using Windows Azure Service Bus Relay
- Integrating with systems behind a firewall from CRM Online using Windows Azure Compute and Connect
- Handling the reporting edge cases using Windows Azure SQL Reporting, Windows Azure SQL Database, and Scribe Online
As I get the rest of the posts published, I will update links in this post. This series is a complement to my Design for Online and CRM Online + Windows Azure = Many Possibilities posts.
CRM Online & Windows Azure: Configuring Single Sign On (SSO)
NOTE: While these instructions may work, they are fairly old. If you are using Visual Studio 2013, there’s a much quicker way to accomplish the same end goal. See: http://azure.microsoft.com/en-us/documentation/videos/azure-identity-application-to-authenticate/
In this video, I walk you through how to configure Single Sign On (SSO) across CRM Online and Windows Azure using Visual Studio 2010. My walkthrough is based on the Web Single Sign-On with .NET and Windows Azure Active Directory walkthrough, but adds the nuances of getting this working with Windows Azure & Visual Studio 2010. If you are using Visual Studio 2012, follow the instructions in the link. If you are using Windows Azure Web Sites instead of a Web Role, then there is an even easier way to configure SSO: http://www.asp.net/vnext/overview/latest/windows-azure-authentication.
In the video, I use Fiddler to redirect https traffic to the Windows Azure Compute Emulator. You can download it here:
Improving perceived performance in a CRM form
In general web development, there are useful patterns to improving the perceived performance in a web page. A great example is this blog post:
Once you understand the core concepts of the post (even tough it’s about ASP.NET MVC), you should be able apply similar patterns with CRM Web Resources. You can achieve the same thing by breaking up your UI pieces into separate web resources and laying them out on the form appropriately. Or you can have separate div tags in your web resource for each thing that needs to be loaded discretely. Often times, in CRM, people want to have the similar spinning loading indicator while the initialization of the web resource is happening. I’ve put together a little sample of how I do it. I’ve packaged it up as a managed solution you can download and review:
Here’s a quick video of it in action:
All I did was add the dkdt_/simulateslowload.htm web resource to the form.
Basically, what happens is when the web resource loads it has the real content hidden. I simulate an asynchronous web service call using setTimeout with a delay of 3 seconds. The idea is that the real content gets fully generated after the web service call is complete. Therefore, a delay. While we’re waiting, I show a loading animation via an overlaid IFrame. Once the 3 seconds are over, I hide the animation and show the content.
Getting a new CRM 2011 Organization ready for XRM
EVEN BETTER UPDATE!!!: Nick incorporated this into an addin for Tanguy’s awesome XrmToolbox. I’d still recommend you read the post to understand how this all works. Also, if you are OnPrem, then the last paragraph of this post will save you even more time.
UPDATE: I’ve modified the post to demonstrate how to fully automate the whole process with sample console app code.
I’ve received a lot of feedback from customers and partners that if you are doing eXtend CRM (aka XRM), then it’s a real pain to have disable the out of the box functionality. Instead, the feedback I get is that what people really want is a clean organization that has:
- A Minimum Privileges Role Template which allows them to turn on the functionality they want to enable for a user.
- Automatically hide Settings and Resource Center from the Site Map.
- Delete unnecessary out of the box Security Roles.
- Hide the out of the box Reports.
- Delete the out of the box Dashboards.
I know a few CRM partners who already have something like this to kickstart their XRM development. I’ve been working on a little side project I just simply call XRM Starter. It’s a combination of an unmanaged solution which accomplishes #1 & #2 and sample code that accomplishes #3, #4, and #5. The sample code also automates the import/publish process. Here’s how to get started…
Download the XrmStarter.zip solution package. It’s an unmanaged solution. Create a new organization using deployment manager. You either import the solution into the new organization using the standard solution import process and perform #3, #4, #5 manually or you can drop the following code into a console app:
var settings = new ConnectionStringSettings(
"anything",
"ANY VALID CONNECTION STRING FROM http://msdn.microsoft.com/en-us/library/gg695810.aspx",
null
);
var crmConnection = new CrmConnection(settings);
var organizationService = new OrganizationService(crmConnection);
var ctx = new OrganizationServiceContext(organizationService);
// Hide all the out of the box reports
var reportVisibilityEntities = from rv in ctx.CreateQuery("reportvisibility")
select new Entity
{
Id = rv.Id,
LogicalName = rv.LogicalName
};
foreach (var reportVisibilityEntity in reportVisibilityEntities)
{
ctx.DeleteObject(reportVisibilityEntity);
}
// Delete the out of the box Dashboards
var dashboards = from d in ctx.CreateQuery("systemform")
select d;
var dashboardsToDelete = new[]
{
"Customer Service Operations Dashboard",
"Customer Service Performance Dashboard",
"Customer Service Representative Dashboard",
"Marketing Dashboard",
"Microsoft Dynamics CRM Overview",
"Sales Activity Dashboard",
"Sales Performance Dashboard"
};
foreach (var dashboard in dashboards)
{
if (dashboardsToDelete.Contains(dashboard.GetAttributeValue<string>("name")))
{
ctx.DeleteObject(dashboard);
}
}
// Delete the out of the box security roles
var securityRoles = from s in ctx.CreateQuery("role")
select s;
var securityRolesToDelete = new[]
{
"CEO-Business Manager",
"CSR Manager",
"Customer Service Representative",
"Marketing Manager",
"Marketing Professional",
"Sales Manager",
"Salesperson",
"Schedule Manager",
"Scheduler",
"Vice President of Marketing",
"Vice President of Sales"
};
foreach (var securityRole in securityRoles)
{
if (securityRolesToDelete.Contains(securityRole.GetAttributeValue<string>("name")))
{
ctx.DeleteObject(securityRole);
}
}
// Send all the updtes to the CRM Web Service
ctx.SaveChanges();
//Import the XrmStarter.zip solution
var customizationFile = File.ReadAllBytes("XRMStarter_1_0_0_0.zip");
var importId = Guid.NewGuid();
var importSolutionRequest = new ImportSolutionRequest
{
CustomizationFile = customizationFile, ImportJobId = importId
};
ctx.Execute(importSolutionRequest);
//Publish the customizations for good measure
var publishAllCustomizationsRequest = new PublishAllXmlRequest();
ctx.Execute(publishAllCustomizationsRequest);
Once you’ve done that, create a new security role by copying the Minimum Privileges Role Template:
Add a User, then assign the user the new role you just created.
Now, log in to CRM as that user. If you are using Windows Authentication, then just run Internet Explorer with the “Run as different user” option and log in as that other person:
http://www.sevenforums.com/tutorials/419-run-different-user.html
…then navigate to the CRM Organization. If you are using Claims or CRM Online, then just start a new Internet Explorer InPrivate session and you will be prompted for credentials when you navigate to the CRM Org. Once you log in as that user, you will see the following:
Notice how the only thing showing in the top level navigation is Workplace, the ribbon is bare, and the only two links under My Work are Dashboards and Reports. If you deleted the out of the box dashboards and hid the out of the box reports, then clicking both links will result in the main content area being empty. I am going to quickly build an entity and a report by going back to my browser session logged in as a System Administrator. You should too, but I am going to skip instructions and assume you can do that yourself. Now that I have created the entity and report, I can update the role to grant read access to the entity I created:
…and if I refresh the browser that’s logged in as the user with the new security role, I see the entity in the Site Map since I gave the role Read access to the ReadOnlyTest entity:
However, notice I don’t have an option to create or edit the entity in the Ribbon. I can run the report on the data:
If I open one of the entity forms, notice how few actions are available to me in the form Ribbon:
I can’t create, update, or delete the record because I only have read privileges. Have a look at the contents of the Xrm Starter Solution:
Most of the work is done by the Minimum Privileges Role Template. Mostly, this is just an example of the power of CRM 2011 role based security in action. Through plenty of trial / error and other blog posts, I was able to get what I think is the right minimal privileges configured for core XRM scenarios. The good news is that if you start getting errors when testing the role, you can just turn the privileges you need on. That’s basically what I did to get to the level of privileges I have configured for the role. When you review the errors you are getting (either through the CRM error dialog or using http://crmdiagtool2011.codeplex.com/), the error messages you will tell you what privXXX formatted privileges are missing. I found the Security Role UI to Privilege Mapping documentation to be very useful to translate the privXXX format into what’s in the CRM UI.
In order to hide the Settings and Resource Center navigation links, I used the approach I mention in this blog post. That’s why you see the privShowSettings and privShowResourceCenter entities and Site Map in the unmanaged solution.
If you are using CRM Online for your dev and test environments, you have to run through these steps for every new CRM Organization you create. The good news is that if you have access to the CRM and SQL servers, all you have to do is maintain a clean organization + these steps copy the organization database using SQL Server Management Studio, and then use the import organization wizard within deployment manager to set up a new org by pointing to that database. Once you have a database as your XRM Starter attached to your SQL Server, spinning up a new org that’s XRM ready is lightning fast!
Visual Studio, ALM & Dynamics CRM
UPDATE (17MAY2013): There’s now a whitepaper on the topic as well: ALM for Microsoft Dynamics CRM 2011: CRM Solution Lifecycle Management
NOTE: I’ve included related links to both Visual Studio 2010 & 2012 content. Even thought the Developer Toolkit for Microsoft Dynamics CRM now supports Visual Studio 2012, I recognized not everyone has upgraded. I do my best to differentiate VS2010 & VS2012 where necessary. You can always switch to the right version of the documentation if you click the wrong link:
I’ve had a recurring discussion lately about using Visual Studio’s Application Lifecycle Management (ALM) tools:
http://msdn.microsoft.com/en-us/library/fda2bad5(v=vs.100).aspx (Visual Studio 2010)
http://msdn.microsoft.com/en-us/library/fda2bad5(v=vs.110).aspx (Visual Studio 2012)
…including Team Foundation Server (TFS), when developing Dynamics CRM 2011 solutions. CRM Development is a little different than traditional software development because you write much less code than building something from scratch (in some cases no code). However, I am a firm believer that CRM projects should be RUN just like a custom dev project. Especially enterprise projects. Enter Visual Studio ALM…
Many think of Visual Studio and Team Foundation Server as just for developers, but if you read through the links above, you will learn there’s much more than what you might think. However, leveraging all of these capabilities in the context of a Dynamics CRM project isn’t really spelled out anywhere. This post is an attempt to be a contextualized table of contents of public information to help people understand how the two worlds collide. The 2010 version of the ALM starter page breaks Visual Studio ALM down to:
-
Plan and track your project. Enact processes and monitor their quality to help your team turn customer requirements into working software.
-
Design functionality, either on top of existing assets or from scratch, by using architectural diagrams to communicate critical information about your team’s software.
-
Write, unit test, debug, analyze, and profile your application by using tools that are integrated with the rest of the application lifecycle so that your team can understand how your progress contributes to the project. Use version control to manage your source code and other files.
-
Build your application by using an integrated build system so that your team can ensure that quality gates have been met and verify that requirements have been fulfilled in each build.
-
Test your application by running manual or automated tests, including performance and stress tests. Manage testing systematically so that your team knows the software quality on any given day.
-
Deploy into virtual environments to enable more sophisticated development and testing.
I’m going to use this as the structure of my mapping to CRM. There’s nothing really specific to Plan and track with CRM. However, I find it surprising how few people are using the Visual Studio planning and tracking tools (work item / bug tracking, reports, etc.) on CRM projects. Definitely review the material to learn about how TFS can help you run your projects. The next area where Visual Studio can really help is Write, unit test, debug, analyze, and profile. With CRM, you “develop” with two primary tools: The CRM Web UI and Visual Studio (usually with the Developer Toolkit for Microsoft Dynamics CRM):
| CRM UI to edit | Visual Studio / Other to edit |
| Entities, Attributes, Relationships Forms & Views Charts, Dashboards, Basic Reports Workflows & Dialogs Templates Security Roles & Field Security |
HTML, JavaScript, CSS XML / XSL Images Sitemap & Ribbon Plugin & Workflow code Companion ASP.NET code |
In may cases, you also use community tools to do things like site map and ribbon customizations. However, in the end, those tools ultimately modify the CRM system (usually by modifying XML files). So the writing code part should be pretty self explanatory through the CRM SDK (online / download) and developer toolkit. The first place where you need to sprinkle in additional CRM context/nuance is unit testing. My posts here should help you:
How I develop and unit test CRM 2011 plugins (make sure to use Fakes instead of Moles if you are using Visual Studio 2012)
Unit testing CRM 2011 JavaScript web resources
Debugging is another place where people get a little tripped up. There are multiple approaches to debugging both plugins and web resources. Debug a Plug-In explains how to attach Visual Studio to the right process to debug plug-in and workflow code. Of course this requires you to attach to the CRM Server. In cases where you can’t, you can profile code execution on the server, save it locally and debug by replaying captured state. See Analyze Plug-in Performance for more details. The CRM SDK has a section on Debugging JavaScript in Microsoft Dynamics CRM. If you are developing your CRM code using a Test Driven Development (TDD) approach with unit testing, then you might come to the same conclusion I came to in my Developing CRM 2011 customizations without a local server post. My personal opinion is that unit testing makes the debugging process much better and improves overall developer productivity. So what about using version control to manage your source code and other files? Remember that most of your non-code customizations can be exported as part of CRM solution export as XML files. I blogged about how to integrate the SolutionPackager tool from the CRM SDK into Visual Studio to source control non-code customizations to help you get started.
The SolutionPackager tool lays the foundation to enable you to build your application on a build server. However, most people who go to the extent of using a build server also want more advanced build automation such as deploying to a test server or virtual environment. While there’s a whitepaper called Deploying Microsoft Dynamics CRM 2011 and CRM Online Solutions from Development through Test and Production Environments which covers some of the nuances of such automation, it leaves much of the work to you to implement. Thankfully, ADXStudio has built the Adxstudio ALM Toolkit which greatly decreases the time it will take a team to reach this level of automation. Shan McCarthur delivered a fairly comprehensive webcast on team development that brings all the core topics together. While the webcast is relatively ALM tool agnostic, it’s not a far leap to understand how use Visual Studio ALM tools after watching and having gone through the material in this post.
What about functional testing? Unit testing is great and all, but not everyone is bought into TDD and unit testing. I always tell people that unit testing doesn’t replace functional testing. However, it usually DOES result in less bugs found during functional testing. The Creating and Managing Tests section of the Visual Studio ALM documentation does a good job of navigating you through the different kind of functional testing it supports. The little gem that I don’t think enough CRM projects are utilizing is Testing the User Interface with Automated UI Tests (aka Coded UI). Dynamics CRM 2011 is one of the many Supported Configurations and Platforms for Coded UI Tests and Action Recordings.
And performance testing? Performance testing is absolutely critical for any large scale software solution. Not enough people do it. The end result is usually finding issues in production when you go live. UGH! Performance testing can prevent lots of heartache. The Visual Studio has tools to help you in your Testing Application Performance and Stress. A compliment to Visual Studio is the Performance Toolkit for Microsoft Dynamics CRM 2011 which is just a set of guidance + additional tools which show you how to Visual Studio Stress Testing Tools with CRM. Stress testing with CRM is a pretty specialized skill. While I’ve given you pointers to the tools to do it yourself, you might want to consider the Microsoft Dynamics Benchmark offered by the Dynamics Premier Field Engineering (PFE) team at Microsoft.
CRM Developer Toolkit & Visual Studio 2012
One of the things I have been getting asked about lately is “When will the Developer Toolkit for Microsoft Dynamics CRM support Visual Studio 2012?” It already does! Just go download the latest version of the SDK. You’ll find a two installers for the toolkit. One for Visual Studio 2010 and one for Visual Studio 2012.
CRM Online & Windows Azure: Improving the SSO experience
This is supposed to be one of a series of CRM Online & Windows Azure posts for which I have been building some samples. While I really wanted to make this the second or third post, someone needed the explanation sooner, so this will be somewhat of a tease to the overall series.
Scenario:
I’ve already configured SSO across Windows Azure & CRM Online. When I try to integrate an Azure hosted page into the CRM UI, I get the following errors:
This content cannot be displayed in a frame
To help protect the security of information you enter into this website, the publisher of this content does not allow it to be displayed in a frame.
This video walks you through why you get the error and how to work around it with a better user experience.
Here’s the code for the two helper pages…
ssoinitiator.htm (CRM Web Resource)
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="refresh" content="5">
<script type="text/javascript">1:2: function getQuerystring(key, default_) {3: if (default_ == null) default_ = "";4: key = key.replace(/[[]/, "\[").replace(/[]]/, "\]");5: var regex = new RegExp("[\?&]" + key + "=([^&#]*)");6: var qs = regex.exec(window.location.href);7: if (qs == null)8: return default_;9: else10: return qs[1];11: }12:13: function redirectToIntendedPage() {14: window.location = decodeURIComponent(getQuerystring("data"));15: }16:17: function bodyOnload() {18: if (document.cookie.indexOf("AZURE_SSO_COMPLETE=") != -1) {19: redirectToIntendedPage();20: } else {21: var message = document.getElementById("message");22: message.style.visibility = "visible";23:24: if (document.cookie.indexOf("AZURE_SSO_INITIATED=") == -1) {25: document.cookie = "AZURE_SSO_INITIATED=true";26: window.open("https://crmazrfedtest.cloudapp.net/SSOHelper.htm");//replace with your azure hosted version27: } else {28: document.cookie = "AZURE_SSO_COMPLETE=true";29: redirectToIntendedPage();30: }31: }32: }33:</script>
</head><body onload="bodyOnload() "><div id="message" style="visibility:hidden"><h1>Initiating Single Sign On...</h1><p>This page will refresh shortly.</p></div></body></html>
SSOHelper.htm (Azure hosted)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SSO Helper</title>
<script type="text/javascript">1:2: function bodyOnload() {3: window.close();4: }5:</script>
<meta http-equiv="expires" content="-1" /><meta http-equiv="pragma" content="no-cache" /></head><body onload="bodyOnload()"><div><h1>Single Sign On Complete</h1><p>Please close this window.</p></div></body></html>
Enable IE10 spell check in a CRM 2011 form
UPDATE: Yes, I am shamelessly promoting IE10 in this post, but this will work in any browser CRM that supports the spellcheck attribute.
Now that Polaris/UR12 is out, CRM works with browsers like IE10 and others that support the spellcheck attribute of the <input/> and <textarea/> tags. According to Spellchecking in IE10, “Spellchecking is active by default on <textarea> and contenteditable elements, and off by default for text boxes.”
As you might expect, the Multiple Lines of Text fields on the form are rendered using <textarea/> tags. Therefore, the spelling error suggestions will be shown. However, Single Line of Text fields are rendered using <input/> tags. Therefore the spelling won’t be checked. I tested this out with IE10 installed on Windows Server 2008 R2.
Notice the first attempt has no red error indicator underlining the misspelled text and the second one does. Fingers crossed that there will be an option in a future release of Dynamics CRM to control configuring spellcheck for form controls. In the interim, you can apply an OBVIOUSLY UNSUPPORTED, but relatively harmless workaround if you really want your textboxes to be enabled for IE10 spell checking. Here’s how:
-Reference jQuery in the form
-Reference a JavaScript file in the form that contains the following function and call it on form load:
function enableSpellcheck(){
$(“:text”).attr(“spellcheck”,true);
}
After applying this, you will see that the text in your textboxes are being checked for spelling errors:
Why is this unsupported? Because the CRM 2011 SDK clearly states here that “HTML DOM manipulation is not supported” when the CRM product owns the HTML. Yes, it’s supported for your web resources because you own that html. The CRM product owns it’s HTML and can never guarantee your code won’t break if you do some wacky DOM manipulation of it’s HTML.
Because of this, I tend to stay away from sharing unsupported hacks. However, this one seems to follow my unsupported hacks rule of thumb. I always ask myself, “what are the potential side effects?” Most of the time, the potential side effects (say after a service update / update rollup) are too risky. In this case, the risk is low but technically unsupported nonetheless. It’s your call.
I tested this out with IE10 installed on Windows Server 2008 R2. You can download IE10 for Windows 7 SP1 / Windows Server 2008 R2 SP1 which you can download in preview form http://ie.microsoft.com/testdrive/info/downloads/Default.html.