CRM Dev Tool for Chrome

A few days ago, Sonoma Partners released a very nice Development Tool. It comes as a Google Chrome extension and it’s compatible with CRM 2011 UR11+ and with CRM 2013. It’s a nice productivity booster for CRM developers so I thought I’d share it. Here are some of the highlights:

  • View Current User Information (domain name, user Id)
  • Form information (entity name, Id, type code and some nice features like show the hidden attributes on a form)
  • Execute Fetch XML statement and view the results

How to use it?

  • Using Google Chrome, install the app from the web store
  • Navigate to a record in CRM 2013 or 2011 UR 12+
  • Press F12 to open the Chrome DevTools Panel
  • Click the CRM DevTools tab on the far right

You can read all the details about the tool on Sonoma’s blog post.

Enjoy!

How to change a Plugin “Run in User’s Context” Programmatically

When you design Plugins for Microsoft Dynamics CRM, you sometime need to have them run as a different user in order to perform operations that a non admin user cannot normally do. This is usually done by using the Plugin Registration tool and setting the value of the “Run in User’s Context” drop down field to a specific value (see screenshot below).

Today I want to show a way to do this programmatically. Our design is fairly simple and the overall goal is to have the appropriate impersonation user being assigned to all required plugin steps automatically without manual processing post-solution import.

  • Create Plugins and steps with the Plugin Registration Tool as usual
  • The name of each plugin that requires to run as an admin user must contain a pre-defined text (in our case [Admin])
  • After each solution is imported to CRM, a plugin fires and look for all plugin steps where the name contains [Admin]
  • Updated the Run In User’s Context field with an admin user defined as per configuration

That’s easy enough. For step 4, where you store the configuration is up to you, it could be registry, XML web resource, custom entity etc.

Here is the code to do it:

Cheers

Dynamics CRM – Year Review from my notes…

2013 has been a huge year for us all Microsoft Dynamics CRM professionals. I thought I would take a few minutes to review my blog stats and make a quick review of what has been helpful to people in the communities over the past 12 months.

The CRM development tools is one of the most popular. The idea back then was to build a CRM Solutions deployment utility to help support a development environment that resembles what MVP Gonzalo Ruiz describes on his blog post. With time, this had become a fairly popular tool available on Codeplex and I’ve received a lot of feature requests. Obviously, with all the time that I have, I was able to integrate… almost none of them J. Hopefully, 2014 will be a better year.

The other very popular article is the one about MSCRM and data archiving. It is something that almost every client will ask for prior to buying a CRM solution and there still isn’t a straight answer. It always depends on why you need to archive, how much money you want to spend on it and who is going to do the job for you. With CRM 2013 coming out and SQL 2012, I may dig into some of the new performance metric and write an update on that topic over the next year.

The CRM 2013 Client API series has been a success as well.

For 2014, I am planning to start by writing a more concise article that highlights the changes in the CRM 2013 APIs including client and server operations. I will also spend some more time evaluating ISV solutions which I cannot wait to get my hands on. In the meantime, enjoy the holidays my CRM people!

Cheers!

Run multiple requests with one service call using ExecuteMultipleRequest

If you have been developing on for Dynamics CRM for a while, you probably asked yourself this question at least one: why is there not a way to send multiple service requests with a single call to the organization service. It’s finally here. It was introduced with UR12 on CRM 2011 and is of course available for CRM 2013. The request type is ExecuteMultipleRequest. It’s really simple to use. Here are the steps and code snippet below:

  • Create a collection of entity records you need to action on (create or update or delete)
  • Create the ExecuteMultipleRequest object and add the settings:
    • ContinueOnError
    • ReturnResponse
  • Add a request for each entity to the request collection
  • Call the IOrganizationService Execute method and passing the ExecuteMultipleRequest object in parameter
public void ExecutePluginOperation(LocalPluginContext obj)
{
IOrganizationService service = obj.OrganizationService;
IExecutionContext context = obj.PluginExecutionContext;

Incident incident = (context.InputParameters["Target"] as Entity).ToEntity<Incident>();
EntityCollection entitesToCreate = GetEntitiesToCreate(incident);

ExecuteMultipleRequest requestWithResults = new ExecuteMultipleRequest()
{
// Assign settings that define execution behavior
Settings = new ExecuteMultipleSettings()
{
ContinueOnError = true,
ReturnResponses = true
},
// Create an empty organization request collection.
Requests = new OrganizationRequestCollection()
};

// Add a CreateRequest for each entity to the request collection.
foreach (var entity in entitesToCreate.Entities)
{
if (entity.Id == Guid.Empty)
{
CreateRequest createRequest = new CreateRequest { Target = entity };
requestWithResults.Requests.Add(createRequest);
}
else
{
UpdateRequest createRequest = new UpdateRequest { Target = entity };
requestWithResults.Requests.Add(createRequest);
}            }

// Execute all the requests in the request collection using a single web method call.
ExecuteMultipleResponse responseWithResults = (ExecuteMultipleResponse)service.Execute(requestWithResults);
}

Notes:

  • You can only make multiple requests that make changes or create entities of different types (e.g. Contacts, Accounts)
  • You can make multiple requests of different types (create, updates and delete requests in a single call)

It’s a very nice performance optimization in certain scenarios!

Qualify Leads in CRM 2013 – What happened to the “Convert Lead” dialog box?

When the CRM 2011 Rollup 12 came out, there was a bug around the “Convert Lead” dialog box no longer appearing during the lead qualification process. Microsoft was originally supposed to release a fix for it in a future release and in the meantime, there was a way to get it to work with “old” CRM forms. It was essentially about adding the Currency field to the form (see details here). Since the new UI came out, it seems the Convert Lead dialog box is gone for good.

Going forward, we now have the possibility to select the existing contact and account directly in the lead record. If none of the value is selected, an Account and a Contact gets created. This avoids additional processing prior to the lead qualification and removes the need to have the “Convert Lead” dialog.

This applies to CRM 2011 Online (instances that haven’t been upgraded to CRM 2013 yet) and all CRM 2013 installation types.