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

Dynamics CRM in Google Chrome

The wait is over – it’s there!





PS. Apparently, the very first javascript customization I checked did not work:) Well, there is work to do.

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

Dynamics CRM: get all updated fields in javascript

I got somewhat strange form behaviour in Dynamics CRM this morning – for whatever reason, at attempt to close one of the phone call records kept brining up a “do you want to save the updates?” dialog. It did not seem to matter that there were no updates, and, even once all the javascripts have been removed, this strange behaviour went on.

I figured that I may need to see which field is causing this, so, here is a javascript code snippet which does this job – if you run into a similar situation, just add a web resource with this code, and, then, add a call to showDirtyAttributes to the “onSave” event of your form:

function showDirtyAttributes()
   var names = “”;, index)
          names += attribute.getName()+”;”;

It actually helped – to some extent. It turned out one of the lookup fields did not like the reference assigned to it for some reason. It did work, I could navigate from that field to the referenced record.. However, I had to update that referenced record and choose it for the lookup once again to finally get rid of the “do you want to save the updates?” dialog.  I’m still wondering what was so unique about that record, though..

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

Dynamics CRM: You can.. call a plugin from javascript.

It’s been generally accepted that Dynamics CRM does not allow us to call plugins from javascripts. And, generally speaking, we can’t call just any plugin from javascript. However, we can still make use of CRM plugins in a little unusual way.

Here is the scenario: there is a client-side java script, and we need to:

- Initiate some server-side processing

- Get the results of that processing back to our javascript

A potential solution to that might be to implement a web service which would encapsulate server-side logic, and to call that web service from our javascript. That might not work with Dynamics CRM online since we can’t deploy our web service on the CRM server, and, so, we may end up with a cross-domain call from our javascript. That’s not to mention that we’ll need to deploy our web service somewhere.

As of now, the only type of server-side processing we can use in Dynamics CRM online is called “plugins”, though. So, can we use CRM plugins in the scenario described above?

Surprisingly, the answer is yes.

First of all, there is a straightforward solution. We might register a plugin which would kick in whenever a new record of specific type is created. We might create a record of that type using javascript; we might pass some parameters to the plugin through the record fields; and, then, we might get the results back through another record (which would be created by the plugin). Would it work? I guess it would. However, we’ll have to work around possible concurrent calls, and, in general, I don’t like the idea of having to store intermediate results in CRM database.

There is another solution which still requires a dedicated entity type, but no CRM records of that type will ever have to be created. Here is how it works:

  • We need an entity to pass data from our plugin to javascript
  • We need to register a post-operation plugin on “RetrieveMultiple” for that entity
  • We also need to register a pre-operation plugin on “RetrieveMultiple” for that entity
  • Finally, we need to have a javascript that will make retrievemultiple request to CRM using fetchxml. That fetchxml will basically ask CRM to return all records of our entity type, and it will also pass whatever parameters we need to pass to the plugin through fetchxml conditions

The point is: such a request from the javascript will activate both of the plugins (pre/post operation). In the pre-operation plugin, we will extract request parameters from fetch xml conditions. In the post-operation plugin, we will populate context.OutputParameters[“BusinessEntityCollection”] with the fictitious records. As a result, our javascript will receive those records, and that’s how it will get data from the plugin. That’s when we’ll have our mission accomplished – we will have a javascript which uses CRM plugins to do server-side processing, yet we will not have to store any data in CRM.

The reason we need two plugins in this scenario is that we don’t have access to the fetch xml in our post-operation plugin, although we still need a post-operation plugin to create results for the javascript.

Basically, all we have to do in the pre-operation plugin is to extract request parameters from the fetch xml and pass those parameters to the post-operation plugin through the SharedVariables collection of plugin context.

In the post-operation plugin, we can do whatever server-side processing we need to do (based on the request parameters that we’ve already extraced in the pre-operation), and, once it’s done, we can populate [“BusinessEntityCollection”] member of the context output parameters collection (in case with this property, we can’t do it in pre-operation.. so, again, we need both pre and post-operation plug-ins in this scenario).

Just to add a bit more clarity, here is a quick diagram:


Finally, here is a real-life scenario where I used this approach:

  • My client wanted to implement javascript-based “behind the scenes” address verification with QAS (
  • QAS web service is hosted on QAS server, so any attempt to use javascript to call that service ends up with a cross-domain call
  • On the other hand, it’s not a problem at all to implement that sort of verification in C#

This fits the scenario described above quite nicely. I have a javascript that makes retrieve mutliple request using fetch xml. There are two plugins on the CRM side. Pre-operation plugin extracts address details from fetch xml. Post-operation plugin makes a call to QAS web service, and, depending on the results of that call, creates a fictitious record  (that record never gets stored in CRM), adds that record to the BusinessEntityCollection, and that’s how my javascript receives the results back.

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

Different faces of Dynamics CRM

I have to admit I’ve been in the trenches, and that’s been happening for quite a long time since I’ve managed to miss this announcement:

“What did CWR Mobility and Microsoft announce?

CWR Mobility and Microsoft announced on February 6, 2012 that the Microsoft Dynamics® CRM Q2 2012 service update will deliver the capability for customers to access the complete functionality of Microsoft Dynamics CRM on any device with a new cloud-based, cross-platform, native mobile client service called Microsoft Dynamics CRM Mobile for Windows® Phone 7, iPad®, iPhone®, Android™ and BlackBerry®  mobile devices.”

See details here:

That did not happen in summer, though. However, Microsoft has recently published it’s December release preview guide which sticks to the point that Dynamics is really going to be supported on tablets and browsers-other-than-IE, so it may still happen.. or may not: 

That, combined with the fact that I’ve spent a couple of days this week evaluating Resco.NET and CWR for the client, multiplied by the fact that most of the users would love to customize Dynamics UI a little(or far) beyond what’s available out of the box, kicked of a different thought process. It would be great if someone came up with a powerful UI framework for CRM applications. Such systems as Dynamics and Salesforce have very efficient backends. However, when it comes to the UI, you suddenly feel like your very basic freedoms have been cut off. After all, I do want to be able to see a different logo when I log in. I do want to play with filters, forms, views – that’s what most of the users will be working with. But I can’t.

And I don’t think I’m alone here, though some people may be taking it to the extreme (or are they?):

What CWR example really demonstrates, though, is that it’s doable, and Resco.NET gives yet another example (On a side note, I’m not sure if I like CWR more).

So, would it be possible? Do you happen to know of any existing UI frameworks that can be easily connected with Dynamics? Should we kick off a codeplex project to finally give different faces to Dynamics CRM?

PS. With that said, December release preview does mention browsers support, and it does not mention native clients. What’s interesting is that it specifically mentions very recent browser versions for non IE browsers(Chrome v22, for instance), which might be a hint of HTML 5 client being developed for Dynamics. December release preview also does not mention support for Android tablets, and CWR does have that support.. So, after all, maybe the deal did not work out and we are going to see something completely new from Microsoft.

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