Monthly Archives: June 2013

Service Activities and capacity scheduling in Dynamics CRM

When working with service activities, we can use out of the box scheduling feature which allows us to choose appointment times based on the resource availability. Resource availability, whether it’s a CRM user resource or a CRM facility resource, relies on the capacity calculations. Many times, we’ll have default capacity for our resources (which is 1), but, in some cases, we may end up configuring a facility with a greater capacity.

As it turned out, that’s where things get a little weird.

Consider the following test:

  • Create a service that only needs 1 resource from any site
  • Create a site
  • Create a facility and make sure to update it’s work hours so that it has, for instance, 100 capacity
  • Set facility’s site lookup
  • Add that facility as a resource to the service

Once it is done, you are supposed to be able to create 100 service appointments for any particular time (which falls into your facility work hours of cause) if you choose the service, site, and facility you just created. That’s because you have a facility with 100 capacity.

The thing is, it does not seem to work as expected. Not all the times, at least.

If you use “Schedule” screen in CRM, then everything will be fine. CRM will correctly calculate remaining capacity, so you’ll be able to create 100 appointments.

However, if you don’t go to the “scheduling” screen and create your service appointment by manually assigning all the lookups, CRM will completely book off your facility for the selected time once that appointment is created. Even if you only create 1 appointment.

A bit of digging in Fillder shows that there is an extra parameter which CRM passes to the server when you use “schedule” button. Do you want to guess parameter name?

It’s called “effort”.

Apparently, when that parameter is missing, CRM decides that your facility has been booked off completely.

I’m not quite sure how to fix it in CRM UI – in my case I was trying to make CRM calculate capacities properly when using SDK, and I was having exactly the same problem. As it turned out, all I had to do (again, in my C# app) is to add “effort” attribute to the resource activity party when creating new service appointment:

resourceParty.Attributes[“effort”] = 1.0;

And that seems to have fixed the problem.

I’ve posted this question to the MS CRM forums, so, if you are interested, take a look there:

http://social.microsoft.com/Forums/en-US/edbd35a6-700d-4583-a0d4-7273c88ab6ad/service-activities-and-resource-capacity

HTML source in Dynamics CRM emails

Dynamics CRM is, likely, not the best tool to do email templating, but, on the other hand, sometimes it’s just easier to send notification emails from Dynamics CRM using a combination of email router and CRM workflow.

The problem with this sort of quick and dirty approach is that there are limits to what CRM allows us to do.. Though, sometimes, there are workarounds which we can apply, so below is one of them.

Basically, I’ve run into a bit of  a problem trying to set HTML source for the emails sent from Dynamics CRM, and here is what happened:

  • Since we cannot update html source directly, I figured I would add a new plain text field (html source) to the email entity
  • And, then, I’ve added that field to the email form
  • The problem with this field was that I could not simply copy the contents of that field to the email description using workflow “set properties” option since CRM kept adding extra HTML body tag to the email description in that case
  • So, I ended up with a simple plugin which I attached to the email entity (create/update), and which only purpose is to copy the contents of my new html source field to the original email description field

Here is the source:

if (context.InputParameters.Contains(“Target”) &&
context.InputParameters[“Target”] is Entity)
{
Entity entity = (Entity)context.InputParameters[“Target”];
if (entity.LogicalName == “email” && entity.Contains(“new_descriptionhtml”))
{
if (entity[“new_descriptionhtml”] != null)
{
entity[“description”] = entity[“new_descriptionhtml”].ToString();
}
else{
entity[“description”] = null;
}

                    }
}