CRM Assistant: Using Expressions

Expressions are in the core of this solution. They are used to set up autonumbers, they are used to create advanced filters, they can be used in the workflow activities, etc.

Basically, expressions are similar to plugins and they are executed on the server. Unlike the plugins, they don’t have to be compiled – instead, they are parsed and executed on the fly. Unlike the workflows, you can use C#-like syntax in the expressions.

Moreover, you have access to the basic C# types (DateTime, int, string, etc) and associated methods/properties. Don’t expect anything fancy like linq.. But you can use the following constructs:

  • Standard arithmetic operators(+,-,*,/)
  • (,)
  • “new” (with most of the basic types)
  • while
  • if  (“else” is not yet supported. As a workaround, use multiple if-s)
  • No need to declare variables
  • Functions
  • Anywhere in the expressions, you can use “entity” keyword to access the entity records for which this expression is being executed

Expressions can be registered for “create”, “update”, “delete”, “retrieve”.  As of this version, they are always executed in the “pre-operation” mode.

Here are a couple of examples of valid expressions

Example 1:

i = 30;
while(i < 20)
i = i+2;

Example 2

function test(i, j)
return i+j;

To create an expression in CRM, and choose “CRM Expressions” under “CRMA”:


In the next post, I’ll walk you through the process of creating an actual expression.

You can download CRMA solution from

Posted in CRMA, Dynamics CRM, Twitted | Tagged , | Leave a comment

CRM Assistant: Getting Started–getting the license

Shortly after you’ve registered at, you will receive an email which will notify you that a new license has been generated for you:


Click on the link in that email, and you’ll see your license details:


Copy license details to the clipboard – you will need it a minute later.

Now open Dynamics CRM and select CRMA there:


Under CRMA, select “CRMA Configuration”:


Create a new CRMA configuration:


Here are a few key points:

-  You can give CRMA configuration record any name
-  You’ll need to paste  license details you copied from earlier to the “License” field
-  For now, ignore “Web Form” fields – we will get to them later

Once the license is deployed, you can start using solution features which will be described in other posts

Posted in CRMA, Twitted | Tagged , | Leave a comment

CRM Assistant: Getting Started–solution deployment

To get started with CRM Assistant solution, you will need to do the following:


  • Download solution files



  • Import downloaded solution file into CRM


Posted in CRMA, Dynamics CRM, Twitted | Tagged , | Leave a comment

A year later.. CRM Assistant is live




It’s been more than a year since I posted that “web forms integration” post below, so it would be a little weird to continue from where I stopped a year ago as if nothing has happened. Well, besides changing a couple of jobs (all Dynamics CRM) and living normal live, I’ve been quite busy getting that “simple” web forms integration solution ready for everyone else to use. It turned out it takes quite a lot to get it done, and it’s probably not there yet.

A CRM solution has to be packaged and tested, there has to be a web site, documentation etc. And, quite frankly, I’m still working on the documentation..

Anyway, check this out:

CRM Assistant for Dynamics CRM 2011/2013/2015

What’s available as of now is:

  • C# – like server-side expressions that can be used in place of plugins (on update, retrieve, create, delete), but that don’t require separate compilation/deployment
  • A custom workflow activity that can run the same kind of expressions
  • Autonumbering for any entity (see above.. expressions are supported)
  • Scheduled workflows (Minimum 5 minutes frequency, no usual recursion-depth limitations)
  • Advanced filters (did you ever want to display all contacts that have a birthday today?)
  • Web forms integration.. actually, CRM Assistant web site is an example of such integration..

Feel free to register, get a trial, and start using the solution. Knowledgebase is coming..

Here is a disclaimer, though: I’m still working on the documentation & additional features, yet this solution will not necessarily meet production requirements. Use it at your own risk – from my standpoint, some of that can be used “as is”. Other features will let you run a quick POC, and, then, based on the results, custom development (plugins/javascripts) may still be required.

Posted in Dynamics CRM | Tagged , | Leave a comment

Is it easy to setup web forms integration for Dynamics CRM?

Here is a teaser.. With all the tools we have at our disposal, how difficult would it be to setup web forms integration without having to purchase a full-blown marketing solution? The answer is.. well, maybe an hour. Of cause you either need to develop an integration solution first, and that would take quite a bit longer. It seems, though, that we already have one.

Let’s have a look at the end result first.. As of today, we are “eating our own dog food” on this site, so gotchahunter contacts page will be a good example. Here is how it works on the high level:



  Gotchahunter is a wordpress blog web site. As much as I love WordPress, I’m not that much into php development, especially when it comes to Dynamics CRM integration. Hence, there is that Azure middle layer that serves as a mediator between Gotchahunter and CRM. The good thing about Azure web sites is that they are, actually, free.. Unless you expect tons of requests, in which case it would probably be ok to pay for Azure traffic anyway. The whole “setting up” process took about an hour, and I’m going to get into the details in the next post. Again, let’s have a look at the end result:

- Gotchahunter contacts page has been updated with a new url. Also, since for each web request there is going to be a lead in CRM, I had to match some of the form picklists with corresponding lead entity fields:



Other fields did not have to be updated – will get to that a bit later

-   Now let’s fill in the contact form:


   And submit the request..

- May take a bit of time to process the request, the there is a thank you screen:


- And here is a lead in CRM:


So what happened exactly?

  1. Gotchahunter site sent all data to a web site in Azure
  2. A web site in Azure contacted CRM server and stored all data in a special entity
  3. A plugin in CRM found a mapping record that defines relationships between source form fields and target entity fields
  4. The plugin then created a lead record in CRM

That’s pretty much it. In the next post, I’ll go into the details on how to enable & configure this integration.

Posted in Dynamics CRM | Tagged , | Leave a comment

Dynamics CRM 2013: Business Rules

Business rules in Dynamics 2013 seems to be a useful feature for at least a few reasons:

  • They can replace javascript validations, at least to an extent. In other words, CRM administrators have an option to implement validations without involving developers/consultants
  • Business rules work for mobile forms
  • They are implemented as workflows(xaml). Potentially, there are customizations opportunities there (I guess they are not exposed yet)

With that said, business rules seem to lack some of the useful features:

  • There are only “AND” conditions, no “OR”
  • Business rules are validated on the client side, so record updates made through SDK will bypass business rules validations
  • Business rules are not in sync with form events. For example, a business rule could be created to set field value when some conditions are met. However, if there is a javascript attached to the onchange event of that field, such javascript will not fire when field value gets updated by the business rule

Either way, if you are interested in a quick walkthrough, here is a good link:

Business rules walkthrough

Posted in Dynamics CRM | Tagged , | Leave a comment

SalesForce: Metadata@JaxbAccesssorF_fullName cannot be cast..

Here is an error message I was getting in the Eclipse environment while trying to refresh metadata (actually, even to create a project):


Luckily, I’m not the first one who ran into it:

Since I’m not a Java developer really, and I don’t always have most recent version of Java in my environment, I figured I would try to update Java first (rather than to install Java 6).. And it helped. So, if you happen to get this error message, see if you have most recent java update.

Posted in, SalesForce | Tagged , | Leave a comment

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:

Posted in Dynamics CRM, Twitted | Tagged | Leave a comment

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();
                            entity["description"] = null;


Posted in .NET, Dynamics CRM, Twitted | Tagged , , | Leave a comment

Recurring workflows in Dynamics CRM

A recurring workflow is, basically, a workflow that starts itself. There have been rumors that recurring workflows in Dynamics CRM can be implemented using child workflow (for example, by adding “wait” step and, then, starting a child workflow of the same type). However, I’ve never been able to really make it work since Dynamics turned out to be very diligent when it comes to terminating this sort of workflows. It usually allows the workflow to run for a few times, and, then, just when you think you’ve finally tricked it into allowing the workflow to go on indefinitely, you see that message that a workflow has been terminated.

Yet we do need such workflows – the most obvious example of why we do is “age” calculations. After all, people do want to send out an email to the customers/contacts having a birthday today.

However, at some point, I actually gave up on the idea to use recurring workflows since I could never make them work.

There are workarounds, of cause. One can write a console application/windows service/etc to do something in CRM periodically. Well, it works for some of us, and it does not work for others. After all, you have to deploy and schedule that application somewhere, and that introduces other issues.

I’ve been dwelling on it for almost half a year, and, it seems, I’ve finally got my “a-ha” moment just a few days ago. There are recurring jobs in CRM, and those jobs are perfectly “legal” from CRM standpoint. One can always create a bulk delete job and schedule that job to run daily. Well, no, not more frequently. You’ll have to schedule more than one job for that.

However, the point is, a recurring workflow can, then, be implemented like this:

  • Create a new entity
  • Schedule bulk delete job that deletes all records of that entity type
  • Add a workflow for that entity which starts whenever a record is deleted
  • Do whatever you need in that workflow (if you need a custom workflow activity, or a plugin.. go ahead)
  • At the end of the workflow, create new record of the same entity type

Here you go – you’ve got a recurring workflow, and CRM has nothing to complain about.

Posted in Dynamics CRM, Twitted | Tagged | 1 Comment