Here’s a quick and easy way to update a plugin assembly in CRM to give much quicker turn around when developing. Note: this will only work if the plugin is deployed to the database.

Plugin assemblies work just the same as all other entities in CRM, which means you can make API calls to retrieve, create or update them. While there is a bit of effort involved in creating new assembly records in CRM and all the associated plugins, steps, images etc. If you want all that to remain the same and to just simply update the deployed code, all you need to do is the following:

var pluginAssembly = new Entity("pluginassembly")
  Id = new Guid(pluginAssemblyId),
  Attributes =
    {"content", Convert.ToBase64String(File.ReadAllBytes(assemblyPath))}

Where pluginAssemblyId is the id of the assembly you want to update, assemblyPath is the path to the assembly file on disk that you want to deploy and crmService is an authenticated OrganizationServiceProxy (see: my previous post to see how to initialise one)

If you don’t know the id of the assembly, you can look it up via the name first:

var pluginAssemblies = crmService.RetrieveMultiple(new QueryExpression("pluginassembly")
  Criteria = new FilterExpression
    Conditions = {new ConditionExpression("name", ConditionOperator.Equal, name)}
var pluginAssemblyId = pluginAssemblies.Entities[0].Id;

Assuming the plugin name is the same as the assembly file name, you could also just pull this from the path:

var name = Path.GetFileNameWithoutExtension(assemblyPath);

  •   Posted in: 
  • CRM

This is an updated list – to extend the original list I made in the post here – of the Javascript bookmarks I have in my browsers, to make my life a bit easier as a power user in CRM. While the latest updates have made navigation a bit easier (especially with the addition of an advanced find button on all screens), I still find many of these links easier and quicker to use.

I have left the bookmarks unformatted because I am a bit lazy, but also so they can just be copied into a new bookmark url box without the new lines messing things up. This does mean that they don’t display so well here, so be warned.

GodMode: I picked this one (including the name) up somewhere along the way (sorry, I can’t find the original link to credit them with it), but tweaked it slightly. This essentially unlocks forms for you. It shows all hidden fields, unlocks all locked fields, clears all notifications and expands all tabs and sections. Use with caution as it can potentially circumvent client side controls and allow you to do things that users shouldn’t normally be able. However, anything important is actually being validated server side as well? Right?


ShowSchemaNames:This does what it says on the tin: replaces all the field labels on the form with the schema names. This is useful as a developer when you need to know the name of the field to use in code and saves time instead of opening up the form or customisations.


GetUrl:Pops up a dialog box with the URL of the current record in it. This gives you a quick way to grab a link to send to someone or open in a new window.


OpenProperties:Opens the properties page that existed in CRM 2011, but isn’t accessible anymore. Gives you an easy way to see created/modified by/on etc.


OpenById:Know the schema name and Id of a record that you want to view? Enter those two bits of info in the dialogs that pop up and away you go.


GoTo… (the following navigate you to the specified section within the CRM organization you are currently looking at.















Users(2013 – where Users is under the Administration section in CRM)


Users (2015 – where Users is under the Security section in CRM)


This post follows on from my post last year about registering Service Endpoints in CRM to send messages to an Azure Service Bus.

If you make use of this functionality and were not aware of the pending certificate expiry for CRM you may have had the unpleasant experience of the messages being sent to the service bus queue (or topic etc) failing in the last week or so (as of 7 March 2015). Basically, for security enhancements the existing certificate expired and a new one was issued to authenticate against the Azure service.

All the information you need is here:

To summarise (and in case that link no longer works): If I was organised and got this post out early, the recommendation would be to login to the access control page for your service bus namespace (https://<servicenamespace> and under Service Settings –> Service Identities add the new certificate for your region (this can be downloaded from your CRM instance under Settings –> Customizations –> Developer Resources or from the links in the article link above). By having the two certificates installed side by side, you would have been able to have continuous service as they transitioned over and could then remove the old certificate at your own time. Now that it is past the expiry date, if you do not have the new certificate installed you should get this installed ASAP and can just replace the existing one. Once the new certificate is installed (give or take a few minutes for the change to propagate), you should be all good to go again.

So there we go. As with a lot of certificate expiry related issues, there is little to no notification that they are about to expire, so is something that as system administrators we need to be aware of and manage accordingly. We now have a few years to get ready for the new certificate here to expire and need changing again.

If you need to create a long running application to interact with the Microsoft CRM web services – for example, something to perform data migration or integration tasks – you need to be aware that, like all good things, web service connections do not last forever.

Note: the following uses example c# code and the CRM SDK libraries to connect to CRM Online.

First up, we need an instance of OrganizationServiceProxy. This can be created like so:

var uri = new Uri(string.Format("https://{0}", orgName));
var clientCredentials = new ClientCredentials();
clientCredentials.UserName.UserName = username;
clientCredentials.UserName.Password = password;
var deviceCredentials = DeviceIdManager.LoadOrRegisterDevice(); //from SDK: SampleCode\CS\HelperCode\DeviceIdManager.cs 
var organizationServiceProxy = new OrganizationServiceProxy(uri, null, clientCredentials, deviceCredentials);

Now, if you check the IsAuthenticated property on this, you will see that it is false. It is not until you actually use the service to do something that it actually gets authenticated. This lazy authenticating can be useful and saves some time when initialising the OrganizationServiceProxy object, as in the above sample. However, if you made a mistake with the credentials you won't actually know at this point, since it isn't until the authentication actually occurs that the provided credentials are checked. This could be an issue if you don't use the service straight away and don't want to wait until it is needed for you (or the end user of your application) to learn that the provided credentials are incorrect.

More importantly, it also means that when the first request is made there is an overhead to it, because it first has to authenticate and only then can it process the request. If you are creating an application that is waiting for user input or another service to call it, it may be better to take the hit straight up so you can then return responses as quickly as possible to the end user.

Thankfully, this is easily resolved: explicitly authenticate the service after creating it:


So now we can get an authenticated connection but, getting back to my initial point, this will not stay so indefinitely. An authenticated OrganizationServiceProxy (against CRM Online at least), has a lifetime of 8 hours, and after this point any attempt to use it to communicate with CRM will result in security exceptions. This is easy enough to work around. Simply add a check before using it to check if the expiry time is coming up and if so call authenticate, which will take a little while, and then carry on with what you were doing.

Rather than trying to add this check before every request to the OrganizationServiceProxy, a better way to do this is to create a subclass of OrganizationServiceProxy and override ValidateAuthentication. This gets called before any other request gets processed, which allows you to write this check in one place and forget about. In this method we, simple add a check to see if the security token is about to expire and if so re-authenticate the service. Like so:

using System;
using System.ServiceModel.Description;
using Microsoft.Xrm.Sdk.Client;

namespace Demo
    public class CrmService : OrganizationServiceProxy
        public CrmService(Uri uri, Uri homeRealmUri, ClientCredentials clientCredentials, ClientCredentials deviceCredentials)
            : base(uri, homeRealmUri, clientCredentials, deviceCredentials)

        protected override void ValidateAuthentication()

        private void EnsureAuthentication()
            if ((SecurityTokenResponse != null) &&
                (DateTime.UtcNow.Add(TimeSpan.FromMinutes(30)) >= SecurityTokenResponse.Response.Lifetime.Expires))

In the above example, I also added Authenticate() in the constructor so when you create a new instance of this it comes pre authenticated and you are good to go and use this exactly as you would the standard OrganizationServiceProxy.

I do not particularly like workflows in CRM. Custom workflows in particular. While I concede there are cases where workflows in CRM can work and that certain custom workflows are useful to add additional capabilities to something a power user can control, from my (albeit rather limited) experience, they are often used (or abused?) outside these situations. Especially where a plug-in would be much better suited.

Unfortunately, I have ended up with a project full of them. With over a hundred different processes and 22 custom workflow assemblies referenced by more than 50 them (some referencing multiple), the system is not my perspective of ideal. Regardless, it has fallen to me to upgrade this CRM4 code base and start to get the system in shape for a future move to CRM2013. 

In preparation for this upgrade I was testing the approach to upgrade the workflows and referenced libraries from .NET 3.5, 3 or earlier and replacing references to CRM4 libraries (i.e. Microsoft.Crm.Sdk) with CRM2011 libraries (i.e. Microsoft.Xrm.Sdk etc) and everything that comes with that (replacing CRM4 types: CrmBoolean, CrmNumber, Lookup, DynamicEntity etc). My initial finding was that an in place upgrade of the code would break a deployed workflow. When you deployed the new assembly it seemed to be fine, however new instances of the workflow will fail. If you try deactivate the workflow and edit it you see this:


All the steps that reference the custom workflow show an error message and you can't open them to edit or delete them. Other than the error icon, it doesn't provide much information as to what is wrong. To have a look at what was going on, I exported the workflows in a solution and had a look at the XAML. Turns out the workflow itself has references to the input field types and being originally CRM4 based, these are the old CRM types, for example CrmNumber. It seems that this doesn't reconcile when CRM sees the new code that we deployed so it gives up. 

The first fix that came to mind here was to update the XAML to fix these references. This is a bit of a pain, but only really another set of find and replaces. However, it turns out there is a much simpler fix within CRM. All you need to do is open up the workflow (deactivate it if it is active) and then open the properties for the custom activities input (the first Set Properties button in the screen shot above). This will show the inputs for the custom workflow, which should all look the same as before. You don't actually need to change anything here (unless you want to of course), so just save and close out. Again, it looks like nothing has changed and the errors are still there, but hit save and close again. Now just open it up again and all of a sudden the errors are gone.


How easy is that! Simply saving the input parameters must trigger CRM to check and update all the parameter types for the workflow, which means the output parameters now match what is expected and the workflow can happily be activated and run. You can confirm this by exporting the workflow again and looking at the XAML.

Awesome, so it seemed like my workflow headaches were going away. That is, until I realised that unlike CRM2011 workflow assemblies, CRM4 did not require the assembly to be signed… and if you sign an assembly it changes the strong name, which means it will not let you provide it as an update for the deployed code, so the above fix was not going to be enough for everything that I was facing... However, how I went about fixing that is a story for another day.