Monthly Archives: August 2017

Your own dev environment is the only real support guarantee when it comes to the open source solutions (aka Github-based).. #DynamicsConsulting

With any open source solution for Dynamics (aka Github-based), the only real support guarantee is to get the source code to your own dev environment and to build it there. Only then can you safely use that solution in production..

Don’t do that, and you’ll find yourself in trouble when the author abandons that solution and you will have to quickly replace it with something else once it stops working after your Dynamics environments is upgraded to a newer version.

Keep your coding skills sharp #DynamicsConsulting

Everyone is sharing uplifting stories these days. So, here is a story..

A client of mine had a custom case management web application which they were moving to Dynamics. That application was built on ColdFusion, it had no technical documentation,  and the one and only requirement for this project was, really, to replicate its functionality in Dynamics while maintaining all the data and data relationships.

That was a government client, so it had some strict policies.. one of those was dictating that their ColdFusion server would be decommissioned on a specific date, so we had to rollout Dynamics solution by that date.

As we were approaching that date, application users started to become more and more concerned. They had to deal with a new system, unfamiliar user interface, new ways of looking for data, etc. They were not shy of doing quite a lot of testing, but they were still not certain they had tested everything, so their main concern was: when the date comes and they are left with Dynamics only, how do they know all the data has been migrated and nothing is left out?

Indeed, how? Keeping in mind that ColdFusion application was almost a black box for us on the Dynamics side, it was not such a simple question.

By the way, at this point an experienced project manager might say “well, apparently you have missed some of the required steps.. discovery, scoping, business analysis, workshops..”, and I would agree to an extent, but it’s a different question all together. The reality was that the cut off date was approaching quickly, and our users were expressing signs of real anxiety since they were starting to feel a little bit like this guy below:

(That’s an image from

We had to deal with that.

And so we did. After all, what is a ColdFusion application? It’s a web site. So, why not to download a snapshot of that site to a network folder, organize the files somehow, and give application users access to those files?

That site has some sensitive data? Not a problem.. We don’t have to use third-party tools since it will take weeks to get them approved – we can develop our own tool in a few days, and it’ll work just as well.  Of course that requires:

  • Development experience
  • Ability to solve coding problems quickly since you can’t afford turning this into another full-scale project
  • Some kind of development environment must be available so you don’t spend time setting it up
  • The outcome of that “mini project” has to be somehow embedded into Dynamics


What’s the end result? About 3 days of work, and we have a read-only snapshot of that original web site stored on the network with all the links to the old data incorporated directly into Dynamics screens. If anyone wants to see that old data the way they used to see it before, it’s readily available. Even if only as a readonly snapshot.

Happy 365-ing, and keep your coding skills sharp!

Albert Einstein and Dynamics

“As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality.”

   –Albert Einstein

There! That’s how I feel about Dynamics most of the time.

Off the top of my head, here is a short list of those Dynamics features that make me feel like Einstein (mind you, that does not mean I’m going to invent another great theory.. but, at least, I can feel the same:) ):

1. Certainly Editable Grids are there now

Yes, but.. not if you are looking at the opportunities associated view subgrid:

2. We can certainly customize Dynamics forms

Yes, but.. not if it’s a “Opportunity Close” dialog (or others like that)

3. We can certainly add filters to the views

Yes, but.. not if it’s a “quick search” view

4. We can certainly use date time conditions such as last x months

Sure we can.. but not unless we are talking about the rollup field filters

5. We can certainly add reports to the entity forms

Sort of.. although, there is that price list entity.. for which we can’t.

6. For sure we can store documents in Sharepoint

Not a problem at all. That’s unless you want to use those documents with the Portals online – you are out of luck if that’s the case.

7. And of course we can customize customer portals on the server side just like we used to do with AdxStudio.

Weeelll.. You know we can’t, right?

8. Here is a good one.. We can not use backspace to clear lookup fields in Dynamics online.

Actually, it’s been fixed in one of the recent updates (not sure which one, but it works in the most recent trial).

9. There are older ones, such as: we can configure security per entity, but not if that’s an activity entity. We can register plugins per entity.. but, of course, not if it’s a order item entity.

And so on and so forth. From a certain standpoint, I like it. If it were all certain and clear, why would anybody need consultants! But, of course, I would probably prefer a bit more certainty.

BTW, feel free to add to that list in the comments to this post:)

Customer Portals: Adding Dynamics integration to the existing site (Part 2)

In the previous post, I got as far as getting the portal displayed as part of my blog’s web page. However, the way it looks “out of the box” is not exactly the way I’d like it to look like. In particular, I still need to:

  • Remove Contoso header
  • Remove Contoso image from the top
  • Remove the footer with all that “about the customer portal” etc
  • I may need to adjust some of the links between different parts of the portal


It seems there are a few things to consider, though:

  1. For some reason, portal signin page is not exposed as a web page/web template. Which means there is not a lot I can do from the customization standpoint.. although, that page still recognizes web site header/footer settings, and, also, it’s using the same content snippets which other pages are using. Remember I need that site header to display postMessage javascript on all portal pages?
  2. Also, there are at least two options this kind of portal configuration can probably be implemented. I can create a new web site from scratch. Or I can use existing web site. Since I don’t really need a stand-alone customer portals site, I’ll just go ahead and modify existing web site configuration to save myself some time


Here is how it all worked out, step by step

There is a content snippet where for this called Navbar Left:


I was going to update the snippet first, but, then, I figure that I can probably just create a new web site header since I may need some other changes there as well. So I did:


That “Embedded Header” has exactly the same content as the original “Header” (copy-paste) except that I have removed Navbar Left snippet from this new template.

Also, notice that I have removed “Footer Template” from the website – when it’s embedded, there is no need for the footer.

When I went back to the WordPress page, Contoso title was not gone yet.. There is another content snippet which need to be updated:


This one is displayed when portal page is not wide enough (mobile device screen), so I had to comment it out (see those HTML <!– –> tags above).

Now it looked better – there was no Contoso anymore.

However, there were still a few things which I needed to fix

At the bottom of each portal page, there is this:


It seems there are a few options to tweak that part, but using FooterCopy for the “Footer/Template” site setting seems to have taken care of everything but of the copyright:


And, to remove the copyright notice, I need to remove all content from the “Footer” content snippet:


Actually, I just renamed the original content snippet and created a new one with “Footer” name. Just in case I’ll ever need that copyright notice again.

At this point, I did not have a footer. Contoso title was gone. However, somehow my iframe got vertical scroll bar back, and, also, there was still that big image on the home page:


With the scrollbar, I’ve found that it helps when I add a line break to the Footer content snippet:


Just like this.. it works, and it’s fine for now.

As for the image, I went to the “Home” web template and updated the source – notice those commented lines below:


Finally, this is close enough to what I wanted to have:





And, then, just when I was thinking it all worked, I hit a little bump here. When I clicked “Open a New Case”, I got a new window:


Which is almost fine, though, since it does not break the user-experience that much. I’m still hoping I’ll be able to apply this and other finishing touches to this integration, but this will have to wait till the next post.







Customer Portals: Adding Dynamics integration to the existing site

What if you wanted to add Dynamics integration to an existing web site rather than to re-create that web site from scratch in the Dynamics Portals?

For example, how difficult would it be to add basic customer portal functionality to my WordPress blog?

I already blogged about using Dynamcis 365 plugin for WordPress earlier:

However, this time I wanted to look at it from a different perspective. There are customer portals for Dynamics, already, so why don’t I try to reuse them?

There are, likely, only two ways I can reuse the portals if I wanted to have consistent design between the portals and my blog.

I might re-create my current blog theme in the portals so anyone visiting the portals won’t notice any difference. And, then, I might actually have two different sites – one for the portals, and another one for the blog. If all the linkage were done properly, my blog visitors probably wouldn’t even notice how they would be taken to different web sites when they would be switching between the blog and the customer portal.

However, this approach has one important drawback. Any time I change my blog theme, which is extremely easy to do with WordPress, I’d have to re-design the portals.

So, I’d rather try another approach, which is all about embedding customer portal into my blog.

In a nutshell, I’ll need to see if I can do this:

  • I will need to be able to display customer portals in an IFrame
  • I will need to make those IFrames at least somewhat responsive so they adapt to the size of the WordPress page
  • I will need to create required forms in the portals, and I will need to ensure that user authentication and navigation works correctly between those forms. Also, I will need to remove all additional branding etc so those forms start looking just as they would if there were create directly in WordPress


That said, let’s see what can be done.

1. Let’s enable IFrames for the portals

When you first enable Dynamics Portals, you won’t be able to display customer portal in an iframe. This is because of the site setting that does not allow iframes, and that’s exactly the one I disabled on the screenshot below:


You can do it directly in Dynamics if you open your web site (Portals->Web Sites) there, and, then, find HTTP/X-Frame-Options under the Site Settings for your side. Open that record and disable it.

Once it’s done, you’ll be able to display customer portals in an IFrame.

Here is how it looks like so far:


I got it displayed, of course, but it does not look that nice yet. At this point, I’m not that much concerned about how the portal itself looks like – pretty sure I should be able to remove the portal header/footer and only leave the form. However, I do need to it to be displayed at 100% of it’s height.

Here is the HTML I used to add that iframe to my WordPress blog page:


Unfortunately, width and height there are relative to the IFrame’s parent page, not to the IFrame’s content. If both sites were in the same domain, I’d be able to use some javascript to access IFrame’s content from the parent page.. or vice versa, to access parent page from the IFrame. As it stands, those are two different domains, though, so this is becoming a little tricky.

2. Creating a responsive portal IFrame

I will try the following to make it work:

  • In HTML5, we can communicate between different windows using postMessage api
  • So, on the blog side, I’ll need to add javascript code to listed to those messages and to respond to them by adjusting the height of the IFrame
  • On the portal side, I’ll need to add some code to send a message whenever the height of the content windows (which is different from the parent window) has changed


To make it a bit easier on the blog side, I’ll be using Code Embed plugin when adding javascripts to my blog pages:

As for the postMessage, you will find all the details here:

And I’ll be implementing this technique below..

Here is the javascript I added using Code Embed:

window.onload = function() {
function receiveMessage(e) {
if (e.origin !== “”)
document.getElementById(‘portalsframe’).style.height =;
window.addEventListener(‘message’, receiveMessage);

Notice that I had to add that code just in front of the IFrame(not after.. I need that code to be loaded first). Also, I have added id tag to the IFrame just so my script above could actually find that iframe by Id:


The screenshot below is specific to Code Embed, of course. You can use other methods to add javascript to a WordPress page, but this is how I did it this time:


So far so good.. Now, if you look at that code above, you’ll see that it’s registering an event listener to receive a message. That message has to be sent from somewhere, and, so, now I need to extend Dynamics portal with a javascript that will be sending that message whenever portal page content height changes.

Luckily, I can use what’s called Content Snippets in the Portals. What I am going to do is: I’ll create a content snippet and I’ll add it to the portal header. Keep in mind that, so far, my goal is to display that portal iframe correctly – I don’t want the scrollbars etc. Once I get there, I can start customizing the portal itself – in particular, I’m thinking of modifying the headers since I don’t really need them when the portal is displayed in an iframe. But there will be time for that. Right now, let’s continue with the iframe.

I just added the following script to a new content snippent:

var lastContentHeight = null;
function notifyParentOfContentHeightChange() {
if(typeof window.parent != ‘undefined’ && window.parent != null)  {
if(lastContentHeight  != document.body.offsetHeight)
lastContentHeight = document.body.offsetHeight;
parent.postMessage(document.body.offsetHeight + ‘px’,’’);

addEventListener(“load”, function()
setInterval(function(){ notifyParentOfContentHeightChange(); }, 200);

  • image
  • This snippet will simply post a message to the iframe parent window(which is my blog page) to notify that window of the content height whenever the height has changed. Unfortunately, I am not aware of an event I could use there to detect content height change in the first place (there is “onresize”, but it’s for the browser window), so I simply had to do it using setInterval. Every 200ms, that code will run, it will check if content height has changed, and, if yes, it will send a notification to the parent windows. And I am also calling it in the onload of the iframe since, otherwise, there can be a bit of a flickering (it can be there anyways since 200ms is still something you may be able to notice.. but it’s a bit of a compromise just in case this starts affecting performance).

And, btw, that had to be a “text” snippet.. “Html” type did not work for javascripts..

Before I can actually test how all this works, I need to add that snippet to the portal’s header web template:


Then save everything.. And let’s see what I got:


Just what I needed. I can, now, use page scrolling just like I would do with any other post or page. As for the IFrame, there is no that additional scroll bar anymore – it’s fully expanded and looks much more natural on the page.

So far, it seems I have managed to set up a page in WordPress that’s displaying Dynamics Portals in an IFrame. There were a few hickups along the way, but it does not look that difficult now that I know how to do it.

However, now that I seem to have figured out front-end “integration” part(well, to an extent, at least), I still need to see if I’ll be able to set up basic customer portal functionality for my blog using this approach. I’ll need to expose login, case management, case history, etc functionality..

Continue reading: Part 2 of adding Dynamics integration to the existing web site

Options sets and statuscode – doing some testing..

There were a few questions in the community forums lately related to some kind of inconsistency in how statuscode optionset behaves, so I figured I’d do a bit of testing tonight.

Here is the set up:

  • I created a new custom entity
  • Added two additional status reasons
  • And, also, added a new option set field


Here is how the form looks like:


I’m going to see how option set control methods work in different situations.

1. Test 1

I’m going to set statuscode and custom field value in the onload of the form:


Here is the result – everything’s good so far:



2. Test 2

I’m going to clear option statuscode and option set control options, then add them programmatically, then set field values:


Here is the result:


That’s exactly why those questions were asked – do you see how my custom field has a value, yet Status Reason is still empty?

3. Test 3

Let’s use the good old setTimeout and see if that changes anything


And here is the result now:



Cool, huh?

I actually have no idea why it’s like that, but I’m assuming there is something about statuscode that makes it different from all other option sets. Maybe it’s the state transitions:

I did not have any of those defined, though.

Maybe it’s the fact that statuscode is dependent on the statecode. Maybe both.

Either way, it seems that, unlike other option set controls/attributes, statuscode control needs a bit of time for the initialization once you have used those optionset-specific methods such as clearOptions, addOption, etc. You can give it that time by introducing a timeout which does not have to be that big at all, it just have to be there, and, after that timeout, statuscode is back in business.

Happy 365-ing!

I do quite a bit of development.. and yet I hate being called a Dynamics developer

Every day I come to work, and I open my Visual Studio to develop yet another plugin / javascript / SSIS package / SSRS report.. And, then, an email comes in from a user who does not know how to do “this and that” in Dynamics, and we talk, and we get back to what we had been doing before (although, either the user knows, now, how to do “this and that”, or I have a new feature request in my backlog). And, then, a project manager shows up and asks if everything is going according to the plan, and I explain that, apparently, not quite, though we may still be able to pull it off.. And, then, I create a workflow to do something quickly.. And a new custom entity.. And a bunch of new fields.. And I don’t normally do business rules – they really feel cumbersome more often than not.

But, with all that, I absolutely hate when somebody calls me a Dynamics developer. That I’m formally on the team that’s doing “development” does not make me a developer. In my mind, I’m a Dynamics Consultant, and, so, I can pick and choose the tools which fit best in every particular situation. Sometimes, it can be a workflow. Sometimes, it can be a plugin. And, quite frankly, I don’t care that much about what the Architect (if there is one on the project) is going to tell me since, more likely than not, we will have to discuss our options once I look into it anyway (but that’s why I prefer to be the Architect.. rather than to give that much authority to somebody else)

So.. This post is going to be much less technical than most of the other posts here, and, actually, it has a lot to do with the discussion Ben Hosking started recently:


The problem is right there..

Apparently, somehow there is a separation between “consultants” and “developers”. But, where I would agree that not every developer is, also, a Dynamics Consultant, I would really disagree with anyone telling me that you can be a Dynamics Consultant without knowing anything about the XRM capabilities.

However, if you know about those capabilities, you’ll be able to make a conscious choice when asked about the most appropriate technique to use in each particular situation.  That’s, basically, what makes you a Dynamics Consultant – your ability to advise the client what the options are. Of course, you might not be that strong on the technical side to develop a plugin from scratch.. But, as long as you understand the options, and as long as you can explain them to the client, you are a consultant.

So, getting back to that screenshot above, I do think that Dynamics Consultants are supposed to be able to choose which technique is best, and that includes development techniques as well. Some consultants might be better developers than others, but it does not mean that any consultant can completely ignore the “development” side of Dynamics.

The reason I hate being called a Dynamics developer is that it sort of pushes me into the corner. Developers are supposed to develop, that’s not my case at all. There is so much more I’m supposed to do on the Dynamics  projects – business analysis, solution design, software architecture, pure coding, users training, pure configuration, maintaining the server, opening support tickets with Microsoft, maintaining the backlog, providing support to the users.. this list can go on and on.

This so-called “Dynamics developer” role is really quite peculiar and there is so little difference there is from a consultant. If you are a .NET developer, your work is focused on the development. But, if you are a Dynamics developer, you have to understand the product first of all – otherwise, your opportunity plugins will be conflicting with the out of the box price calculations, your validation plugins will be missing some unusual scenarios, and so on. Once you get there, you suddenly become a consultant, and, at some point, you will find yourself saying “well, I think it should be done with a workflow.. or, wait, it would be even easier to just configure a parental relationship.. although, how about this OOB workaround?”. But, when it’s called a “developer” role, that sort of implies certain things about what the person is supposed to be doing, and this is where things can easily go wrong because of the incorrect expectations on both the client and the “developer” sides.

So, call me all you want, but don’t call me a developer.. despite all the development I do every day. Dynamics Consultant would be just fine by me, although, if it’s a Dynamics Solution Architect, it’s, probably, even better.. since that gives me a bit more “authority” in terms of making decisions.

How to: roll up without limitations

Rollup fields in Dynamics are great, they are very useful, they are there out of the box, and a lot has been written about them.

Although, if you wanted to start somewhere, the page below would give you all the details:

That said, there is a bunch of things you can’t do with the rollups:


This list is rather long, so, if you’ve been using rollup fields on your Dynamics implementations, you have probably run into some of those limitations.

I would add two more that came up recently in the community forums:

–  You cannot use a rollup to calculate the number of notes associated with a particular case (it’s probably the same with any other entity – can’t rollup over notes). No way to select notes below:


– You cannot create rollup fields on some entities (for example, there is a “Characteristic” entity which, somehow, does not allow rollup fields). There is just no rollup option:


So when this happens, when we run into a limitation, what can we do?

  • We can develop a plugin
  • We can develop a custom workflow activity
  • We can use javascripts
  • And there are, probably, other options as well


I wanted to show you how to do it with TCS Tools, though, since I just updated that solution to better support all those rollup scenarios. In a nutshell, all you need to do to define a custom rollup is:

  • Create FetchXml to query the data
  • Create a workflow that will use that FetchXml to update a field


So, let’s say we wanted to get the number of notes per case.  In one the earlier posts, I already described how we can use “Lookup Setter” custom workflow activity to set a lookup value:

In the most recent version of the TCS Tools, that custom workflow activity has been renamed to “Attribute Setter” to better reflect its capabilities.

Here is how I am going to use it to count those notes:

  • I will create a whole number field on the case entity (Notes Count)
  • I will create a Lookup Configuration record to define fetch xml which will use aggregation to get the count of notes per case
  • Then I will create a workflow on the case entity (a  “child” workflow) which will use “Attribute Setter” custom workflow activity in combination with the fetch xml defined above to calculate notes count and to set “Notes Count” field. This will be a background workflow
  • And, finally, I will create a workflow on the notes entity which will be triggered on create/on delete of the note records and which will be calling that workflow on the case entity as a child workflow. This will be a real-time workflow


Why do I need two workflows? Because I want to do those calculates “on delete” of the note records, too. But, if I make it a real-time workflow, it will run before note record is deleted. So the note being deleted will still be counted, and I don’t want that to happen.

And, btw, if you wanted to know more about FetchXml aggregations, I would suggest this link:

Let’s get ready:

1. I need a new attribute on the case entity


2. I need a lookup configuration record


Here is what all those attributes mean:

“Name”: just a name. I’ll use it when setting up the workflow later

“Fetch Result Attribute”: where the result will be once my fetch xml is executed

“Entity Attribute”: this is the name of the attribute where the result will be stored

“Update Direction”: Entity. I want to update case entity, not all the records which will be retrieved by that fetch xml

For your reference, here is my fetchxml:

<fetch distinct=’false’ mapping=’logical’ aggregate=’true’>
<entity name=’annotation’>
<attribute name=’annotationid’ aggregate=’count’ alias=’count’/>
<filter type=’and’>
<condition attribute=’objectid’ operator=’eq’ value=’#incidentid#’ />

Notice how I’m using #incidentid# there. This allows me to choose only those notes which are associated with the case for which my workflow will be running.

3. I need to create a workflow on the case entity



Again, that’s a child process workflow.. I’m using Attribute Setter workflow activity.. And I’ve set up that activity to use my Notes Count lookup configuration from step #2.

Almost there, but I still need to call that workflow somehow

4. I need a workflow on the note entity

In this workflow, I will check if that notes record is related to a case, and, if yes, it will start my child process workflow from step #3


And that’s it. It is time to roll up!


Happy 365-ing!

Dynamics and WordPress, the follow up

Not sure if you’ve seen my previous post on using WordPress with Dynamics – that was merely a beginner’s attempt to connect WordPress to Dynamics.. however, folks at AlexaCrm (those guys who developed the plugin) did see it, and, apparently, they figured they couldn’t leave it that waySmile

In particular, George Doubinski got in touch and suggested that I took a look at the demo site that’s using the plugin.

Well, I was pretty sure there is a lot more you can do with this plugin when I was writing the previous post.. It turned out we can probably do even more. But let’s have a look, should we?

1. Here is the user profile screen


All it takes to display this form in WordPress is:



2. Do you have any support cases? Here is your standard client-portal case management functionality..
See your cases, create a new one..

You would think this one should be much more complicated? Hmm..

3. Now let’s see if there were notes on the case



This is, actually, a little more complex:



Apparently, this plugin can do a lot. The obvious question is, then, if it’s comparable to the Customer Portals from Microsoft.

This is where it becomes really interesting because, I think, it’s a wrong question. The right question would be if WordPress, combined with this plugin, is comparable to the Customer Portals from Microsoft.

In both scenarios we have some level of integration with Dynamics. However, this seems to be one of those classic battles.. On the one side, there is WordPress with its huge following, long history, and lots of successful implementations which are not limited to Dynamics. On the other side, there is Microsoft with its very custom portal solution which is based completely on Dynamics, which is still new, and which, with the introduction of this plugin, still has to answer the question of why it’s actually better.. because it’s not the only Dynamics-integrated portal solution now.

From the site management/content management perspective, I have a feeling WordPress will beat Dynamics Customer Portals solution easily. But, then, how much integration is, really, needed between a web site and Dynamics to make Customer Portals a preferred solution?

Does it really have to be integrated to such an extent that content management is done completely in Dynamics? Does it even make sense to turn Dynamics into a site management tool? Or is it sufficient to simply provide integration on the forms/view level (have a look at those screenshots above again) and leave site management to the specialized applications/solutions?

Guess I’ll just leave it there for now.. But, either way, well done, AlexaCRM:)

PS. If you wanted to see documentation for this plugin, you’ll find it here:


Unlocking “add new” on the subgrids for read-only records

Here is what recently came up in the community forums:

  • There is a contract line out of the box entity
  • There is a custom entity that has a lookup to the contract line
  • There is a subgrid for that custom entity on the contract line form

So why don’t we see “+” button next to the subgrid when the contract line is in one of the read-only states?

Interesting question, actually.. And I’m not sure it used to be the same in pre-365 versions of Dynamics.

However, this is where Ribbon Workbench can get us the answer quickly. Let’s do this

1. Create a solution in Dynamics

2. Add our custom entity to the solution (don’t need to add anything else)

3. Open XrmToolBox (

4. And install “Ribbon Workbench” plugin from the store

5. Connect to the organization and open Ribbon Workbench

It will ask for the solution to download, so let’s pick the solution created above:

6. Once the solution has been downloaded, do this (step by step)

  • Make sure you have your child entity selected in the entity list
  • Then chose the button (#2) on the screenshot
  • Right click on the button and select “Customize Command” option

7. You’ll notice that the area below will reload..

And, in particular, there will be that Mscrm.EntityFormIsEnabled rule.. Which is the reason for all these problems.

That rule is basically saying that the parent form has to be active for the “add new” button to work.

What do we do next? Let’s delete the bugger..

7. Delete the rule

12. Hit “Publish” and wait for the confirmation (this may take a few minutes)


It’s time to go back to that contract line screen and hit F5 in the browser:

Here you go.. The miracle of Ribbon Workbench has saved us again!