torsdag 19 december 2013

New feature in CRM 2013 on activities

I have been struggling with a problem to relate emails to "parent email", i.e. the email you're replying to, during the past week. The upgrade to CRM 2013 made on of our solutions very much obsolete. The solution of the problem did make me happy though, good work Microsoft!

We created a solution in CRM 2011 where the sender address was set to the address of the queue the email was in instead of the user. This is very much a standard configuration of pretty much ALL ticket systems I have been working in while being a support engineer. That the service parts of CRM doesn't have this feature out of the box is a mystery to me.

The old solution was to use a queryattribute called _InReplyToId, which was the GUID of the email you were replying to. The queryattribute wasn't present in CRM 2013 and I have been looking for a solution ever since. The solution was in fact very simple, Microsoft has provided a connection to parent activity called ParentActivityId. When responding to an email this field is populated with a lookup to the original email, just add the field to the form and you can access this with regular JS code.

To set the sender address to the address of the queue you will have to look up the queue item of the parent email, and fetch the queue from that. I chose to to this with an OData call which I've grown quite fond of the past months.

I think this will help quite a lot and it's really a great feature of the new CRM.

Rickard Norström
Developer at CRM-Konsulterna    

tisdag 17 december 2013

Security roles impact on updated CRM 2011

Since the upgrade from CRM 2011 to 2013 some things have most definitely changed. Some of these changes seems very strange and as soon as the security roles are involved things often are a bit of a challenge to troubleshoot.

One of our customers have a customisation that adds "synchronisation users" to contacts. This is used to sync contacts to more than the owner's outlook. In CRM 2011 there wasn't a problem to add users to the contact with the N:N relation that we created, but after the upgrade they weren't able to add users to the contact.

Of course, when I logged in it was working and since I was using the sysadmin role the answer seemed to reside in the ever so funny security roles settings. It always amuses me to find the correct setting. This time I went through the roles to find the one with least privileges to try to match what was happening. The role I started off with was the CEO-role, which I started stripping of rights until I couldn't add users anymore.
Before I did this manouver I started off by guessing which rights that were needed but since that didn't help I went straight into trial-and-horror-land. The answer confused me a bit at first since the answer was to give users create rights on the user entity. When I opened the search on the quick add field I realized that there was a "new" button at the bottom which probably was evaluated before you could add an existing user.

There is some sort of logic behind this, however it would please me if the "Add existing user" button didn't need a create user privilege to be able to add an EXISTING user. The entire security role part is in my humble opinion somewhat hard to grasp and understand when you move out of the clear areas. To have to have the right to create a user to be able to add an existing one is one of the examples I have encountered during the past years but I could probably make quite a list of these examples.

Happy holidays and great new year!

Rickard Norström
Developer at CRM-Konsulterna    

fredag 1 november 2013

Upgrading CRM 2011 to 2013

Now that we finally got our hands on the much anticpated Dynamics CRM 2013 some of us will be facing upgrade situations at our customers. To upgrade CRM 4 to 2011 was a quite nice experience, have that changed for 2013?

I have been doing a fair share of installations of Dynamics CRM 2011 installations and upgrades which has given med some gray hairs at times but for the most part been sort of smooth. I'm not counting the IFD installations I've done as smooth in all areas, but they are managable when you get used to it. After installing a CRM 2013 server that will be used as a lab machine, I thought it would be entertaining to do a test upgrade of one of our old CRM 2011 machines.

So, I started by installing a CRM 2013 on top of one of our lab servers, being the man I am I totally ignored to read the implementation guide, this would of course bite me in my rear side, pretty quickly too.

It all started fine, I double clicked on the install file, then it stopped going fine. "This version is not supported", what the h....So I would have to do something radical, read the implementation guide, great shame. So, what went wrong? According to the IG the supported versions are UR 6 or later than 14. However you are recommended to install the latest version, so, I installed UR 15 on the server. 
Continuing to read the IG it also recommended to uninstall the SRS on the system to be upgradet, done. Now I was ready to upgrade.

Or so I thought. Next stop was that I got an error about something not being right, and if I wanted to know why I was to open <username>\AppData\Roaming\Microsoft\MSCRM\LegacyFeatureCheck.xml. Now, why on earth isn't there a button saying "Click here to open this log that you will need to look at in order to be able to continue" (or perhaps something shorter lite "click to open log"), however in my case the problem was a component we had tested that was present in the ISV folder. This is now completely depricated and CRM 2013 won't be installed if there's data in the ISV folder. The log indicates that the server install tool checks for CRM 4.0 plugins, CRM 4.0 SDK references and CRM 4.0 web service endpoints usage.

Now, all is ready to go after cleaning out the ISV folder I ran the server install and selected one of the existing organizations to upgrade and it all worked smoothly. After the install/upgrade the SES installation kicked in and then there was a CRM 2013 lab environment available.

All in all I would have to say that both installation and upgrade is a relatively smooth operation once you get past the little bumps of say, actually read the manual. One thing that you might want to have a closer look at is the part of the implementation guide that covers merge of database tables at a later time. CRM 2013 doesn't split the enity tables into base and extension any longer so when you upgrade an old organization these tables are merged. If you have a large organization you might want to do the DB merge in a service window since it is quite a large operation. The instruction is available in the implementation guide. It is quite a list to go through but seems quite manageable.

Rickard Norström
Developer at CRM-Konsulterna    

onsdag 11 september 2013

More fun and games with currencies and solutions

Quick post this time. I posted an observation with currencies and workflows in solutions a while back, this baby just keeps on giving.

The problem was that when you import a solution with a workflow that contains a currency you have to change the currency name in the receiving environment to match the currency name in the "dev" environment. Now we moved the dev to a new server and did a backup/restore of the database in which I had changed the currency name to match the receiving environments even though it didn't work. To my surprise the import of the organization on the new server actually changed the name of the currency in the solution and now I don't have a mismatch. I bit confusing but very nice.

Rickard Norström
Developer at CRM-Konsulterna    

måndag 26 augusti 2013

Javascript and console

To write info to the console when you are working with javascript is a nice way to avoid a ton of alerts, however this way of keeping track of things have a slight downside

This downside is that in some browsers the console isn't available. In this case I discovered the problem with IE9. I had a javscript which was using"Some interesting info") to keep track of things that was happening in a function. The "funny" thing was that in the production environment I was accessing the CRM from my own machine running IE10 or Firefox 22 which wasn't giving me any problems, everything was working peachy. However, in my development environment I was using IE9 and in that case you need to have the developer tools open (press F12) otherwise there is no console available and the javascript crashes, silently.

The easy solution is to have an if-clause saying "if (window.console)" that checks if there's an available console to put stuff in.

Rickard Norström
Developer at CRM-Konsulterna    

onsdag 19 juni 2013

Workflow won't import properly due to currency error

This problem has bugged me, litterarly, for some time now. When I moved a solution from dev to test I got a lot of errors on Workflows due to error in the currency. It was not a great problem in most cases since I just changed to an existing currency. The big issue occurred when I had an email template in the Workflow.

The problem was the following: The name of the base currency, which was the one used, was SEK. In dev the display name was "Svensk krona" and in test the display name was "Swedish krona". When the workflow was imported, CRM couldn't match these. At first I thought it was a guid mismatch as it is with teams used in workflows and it was pretty straight forward to just change the currency in the Workflow. However, when you use an email template to send email, there is no currency field to change and the currency is still set somewhere.

I found a solution to my problem at Dynamics CRM Funda  blog. The solution is to rename the currency display name on the receiving system to match the source system before you move the solution, afterwards you just change it back.

A bit akward I think but it works. A nicer solution would be to use the currency code as match instead of the display name, but again just change according to the reality.

Rickard Norström
Developer at CRM-Konsulterna    

tisdag 30 april 2013

Email router configuration

The Microsoft Dynamics CRM 2011 Email router is almost an endless source of joy. One of these is to make it work. I wrote this for my own reference since it might be some time between the occations I have to setup an email router. 

The first thing you do is to launch the Email router configuration manager and what greets you is the profile tab. In this tab you set up incoming and outgoing profiles for your deployment(s). There needs to be at least one incoming and one outgoing profile, but in most occations there will be more of these.

To create a profile click the "new" button on the right. Here you have a couple of choices, the first one being to give your profile a name. In this example it will be "incoming" and the profile will be for incoming mail.

Here I have chosen a POP3 email server which gives us a couple of choices to make. One is Authentication type which can be NTML or clear text, I have chosen the latter here. With clear text it's recommended that you use SSL.

Then you just enter the server address and which credentials you want to use, in the case of POP3 you can choose "other specified" and "user specified". In this screen shot the other specified is marked and as you can see the user name i determined by the email address and that the password window is empty. This means that the user or queue you will associate this profile with will have the email address for user name and a password stored in the Email router. This means also that all users and queues using this profile will have to have the same password, which is NOT recommended and thus you need a profile for each user/queue and you need to update that profile each time the user or queue change the password. That is not good in a couple of ways, one being that you will need the password of the user and that's not best practice in any way.

 If you choose another email server type, for example Exchange 2010, you get another set of options. For Exchange Server 2010 the only way to access the server is using the web services which have a URL. This is entered in the location window and looks something like "". In the screen shot I have just changed from POP3 to Exchange 2010.

For cretentials you have the same choices as in the POP3 case, but you can also chose "Local system account". The "other specified" looks a bit different from the POP3 case too. Here you can enter an admin account which has access to the email boxes that you want to use the router for. The same goes for the Local system account. I haven't used any of these in a live system and have been told, rather harshly, by an exchange expert that you don't want to do that. The third choice is user specified. This means that the user enters credentials into the CRM and those are used to access the email box, seems like the best way to handle this if you're using Exchange.
The result looks something like the image to the left. Another thing to think about if you're using Exchange 2007 is that the Webdav protocol doesn't seem to like some characters. We've had the entire router service shut down when an email entered the inbox with a subject containing a character that the email router did not appreciate.

 Now, the next thing we do have a look at is the Advanced tab.
Here we can change the ports we are using to connect to the server, this is definitely needed when changing the protocol to SSL.

 Now that we've done our incoming rule we need an outgoing rule. Again there are a couple of choices needed, the first being the name, next we choose outgoing for direction and in the second drop down we can choose either exchange online or SMTP. For this example SMTP is our choice.

 Then we have the authentication type. The choices being Windows Authentication, clear text and Anonymous. To be able to use credential type "Local system account" you need to use Windows authentication. Again, if you use clear text be sure to use SSL. After you choose authentication type, you need to enter the url to the SMTP server and finaly choose Access credentials.

In the next screen shot I have made my choices, in this case Clear text which only give me the choice of other specified for credentials. As you can see I've entered a username and a password in the credentials input fields. If I would have chosen anonymous, those fields wouldn't be available.
Again, the Exchange expert I was talking to recommended that you did not use anonymous access to the smtp server. Further she didn't like the idea of one user being able to send emails in the name of everybody in an organization. With this info on hand, the outgoing profile is more or less useless for everyone except queues, and even in that case it's quite a lot of job maintaing the system if you have a lot of queues. One thing I fins a bit curious is that you can't have the user specified credentials for outgoing email, that would have solved some problems at least.

If you need to change some port settings, the advanced tab looks roughly the same as the incoming rule advanced tab.

Now you are done with the profiles and you have a profile tab looking something like this.

Let's move on to the deployment tab. Here you set up wich CRM deployment you want to use. Again click on the "New" button on the right hand side and you get a new window with settings for the deployment.

Here you can choose to use an on-premise CRM, a partner hosted CRM or an on-line CRM. I chose on-premise (My Company) and entered the url for the crm, complete with port and organization name. Then I entered a user after chosing "Other specified" as credential type, the other choice is Local system account. Make sure to use a user with enough rights in the CRM, otherwise it might work in an unexpected way. The last two dropdowns specify if you want to use any profile as default, I chose not to do this.

After that is done we want to link our users and queues to profiles, that is done on the last tab
Here I have already clicked "Load Data" after chosing my deployment from the dropdown. All email router enabled users and queues from the organization are shown and you simply open them and add an incoming and/or outgoing profile to them. After that is done you press the "Test Access" button to se if there are any obvious errors done.

As you can see all data is entered correctly and the test went ok.

Now, this doesn't mean that it will work, this means there are no errors in the setup. And this ends this quick demo of how you set up a email router for CRM 2011, and CRM 4.0 since they differ very little if they do at all.

Hope this helps!

Rickard Norström
Developer at CRM-Konsulterna    

torsdag 11 april 2013

The CRM Email router routing emails into unexpected queues.

I've been working with the email router a couple of times the past few weeks and each time is a new bag of funny stuff. This jewel just keeps on giving.

The latest bit of interesting behaviour I found was that when an email is sent to two or more different queues it actually gets queued in all of them. This was a certain blog topic in my little head, but just to be sure about it I did a bit of resarch and found this blog which proved me wrong in my thought that an object only could be present in one queue at a time.

However, there was another thing that caught my interest and that was that a queue that isn't active on the email router can get email into it.

The queue support3 is set up like this in CRM and has no rule on the email router since it's just an alias.

This was a bit curious since I hadn't got an incoming rule set up for the queue. This is not that exact email but I reproduced the behaviour. What happened on the customer's system was that they were re organizing their incoming email and had a bit messy system for it so they forwarded the email from one address to another mailbox and we were polling that mailbox. Now, I tried to set up a queue using the email address that was being forwarded on the emailbox that had another username. This was not so popular with the email router setup so I reverted to the email address that matched the username. In this example it is support2. When I enabled that incoming rule on the email router, emails started coming into the queue of the forwarded email address.

What happened was that the email router polled the incoming box of support2, finding the email addressed to support3, looked the queues and found a match in support3 and delivered the email to support3.

Needless to say, I was a bit confused. I told the customer what just happened and he looked at me asking does the email enter the system and end up in the correct queue? Well, sort of, not the queue we planned it to enter, but the old queue. Fair enough, let it be, it's working.

I don't know if this is the way it's supposed to work but it could be a shortcut getting email into the system using one email box and a heap of aliases. Sort of the forward email box but without having to put the original email into an attachment.

Rickard Norström
Developer at CRM-Konsulterna    

söndag 24 februari 2013

Powershell on ifd server

Configuring Internet Facing Deployment is no easy task by itself and when you're done, well the CRM is up and running at least, it's easy to miss some of the settings that's needed.

This might not be the case for everyone doing this but it certainly was to me. I had been struggling with the ADFS and IFD for some time that it started to be something of a blurr what I had been changing and what was untouched. Anyway, the CRM was up, the IFD was working, everyone's happy.

What happened next was that the disk was getting full on the server and I noticed I had forgotten to turn off the trace. Since this can be done either by the registry or by changing the database with powershell I started by looking at the registry and no keys were set there, moving along to the database using powershell.

The good-ole' "Add-PsSnapin Microsoft.Crm.Powershell" gave me no headaches, that was about to change though. When I entered "Get-CrmSetting TraceSettings" the following message returned:

Get-CrmSetting : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
At line:1 char:15
+ Get-CrmSetting <<<<  TraceSettings
    + CategoryInfo          : NotSpecified: (:) [Get-CrmSetting], WebException
    + FullyQualifiedErrorId : System.Net.WebException,Microsoft.Crm.PowerShell.GetCrmSettingCmdlet
 This made me a bit confused since everything else was working fine. A bit of searching lead me to looking at the Deployment manager and what was set there.

This is what the Web Address settings looked like and the IFD was pointing at The solution to my problem was just to change the web address to that of the IFD and bingo, powershell was happy again. To turn off the tracing of the CRM server is a different story, that part lives it's own life.

Rickard Norström
Developer at CRM-Konsulterna    

torsdag 31 januari 2013

CRM has encountered a problem

I recently ran into the annoying pop up when I closed a window saying CRM has encountered a problem... asking if I wanted to send a message to Microsoft. When I looked at the info about to be sent, the error message was "The disk is full".

This made me a bit worried since I just cleared trace logs since june on that machine after a lot of testing and reconfiguration of the ADFS and IFD. The disk was far from full I realized after logging in to the server and taking a look, no problems in the database either.

I tried to find similar errors but there were no real answers for me which turned me to Microsoft's forum where I asked a question about this.
The obvious answer I got was "Have you turned on trace and looked at the logs?". That was of course one thing I hadn't done, even though I had a look at the trace directory, and an almost as obvious return question as "have you published your changes".
The trace gave me a clue about where to look since the culprit was the "refresh.png" in the Activity Feeds addon.

This clue gave me a bit more to go on and there were indeed quite a few having problems with activity feeds i general and the refresh.png in particular. One thing that was common was that the error message in the trace gave the path as ".../refresh.png" when the web resource name is ".../msdyn_/refresh.png". The second path was accessable with a browser and the first one wasn't. Still I have had Activity Feeds work on several installations so the addon itself can't be the entire problem.

On the website for Activity Feeds I saw  few comments about Activity Feed not being available in this or that langage. That made me a bit curious since we had an English server installation with a Swedish MUI on top and the tennant I had problems with had Swedish as base language.
I opened the organization and enabled English, refreshed the Explorer and bingo, no problems anymore.

This raises a few questions. Why can Activity Feed translade a faulty URL when there is English provishoned? Why did the Swedish base language mess things up (I suppose) and why on earth is the error message sent to Microsoft "The disk is full".

The error messages in CRM is a story by itself so this is no "one hit wonder".

Rickard Norström
Developer at CRM-Konsulterna   

fredag 25 januari 2013

CRM 4.0 upgrade quits with error Attachment file size is too big.

I recently had an assignment to upgrade a CRM 4.0 to CRM 2011 which at first looked like a very straight forward upgrade since there were close to none customizations done to the system. That quickly changed when I started the upgrade process which halted with the error message "Attachment file size is too big". It seems no one encountered this problem since there wereno relevant examples of how to deal with it.

What seemed like a very straight forward migration upgrade soon turned into something of a stand still. I had installed the new server which went very good and the old database backup was restored to the new SQL server. It was a 16 GB database but there were no customizations to talk about.
I was rather pussled when the upgrade returned an error about Attachment size to big, I hadn't seen that before, nor had my colleague Gustaf Westerlund, and I didn't recall anything about it in the installation material either. The error message in the trace looked like this:

12:34:29| Error| Exception occured during Microsoft.Crm.Tools.Admin.OrganizationUpgrader: Action Microsoft.Crm.Tools.Admin.UpgradeNewSolutionAwareEntities failed.
Microsoft.Crm.CrmException: Attachment file size is too big.
at Microsoft.Crm.ObjectModel.AttachmentServiceBase.ValidateAttachmentFileSize(Int32 base64dataSize, ExecutionContext context)
at Microsoft.Crm.ObjectModel.AttachmentServiceBase.Update(IBusinessEntity entity, ExecutionContext context)
at Microsoft.Crm.ObjectModel.MailMergeTemplateService.Update(IBusinessEntity entity, ExecutionContext context)
at Microsoft.Crm.ObjectModel.SolutionsUpgrade.SolutionAwareEntityUpgradeBase.Upgrade(ExecutionContext context)
at Microsoft.Crm.Tools.Admin.UpgradeNewSolutionAwareEntities.Do(IDictionary parameters)
at Microsoft.Crm.Setup.Common.CrmAction.ExecuteAction(CrmAction action, IDictionary parameters, Boolean undo)

I turned to the safest place to find answers, the INTERNET.

Normally when I search for information about CRM I get a ton of links pointing in all types of directions. This time there were two pages total, not a good sign. It would be clear that almost none of them handled my particular problem, most of them pointed out that you need to set the attachment size in the settings of the organization which wasn't an option.
Or so I thought.

Since we wanted to rule out the customer's server I moved the database backup to one of our development servers which gave the same result. The next move was to import the database to a CRM4 server in our development environment, perhaps it would help to get a higher UR of CRM 4. The import to our development CRM 4 server went smooth, no problems at all. This made me very hopeful but that hope went right out the window when I made a new backup of the imported organization and restored it on the CRM 2011 server, still problems with too large attachments.

It didn't help to edit the web.config to increase attachment file size either. However, that I was able to import the organization to our CRM 4 server made me a bit hopeful. It was possible to import the organization to a CRM 4 server but not to upgrade it to a CRM 2011, how was this possible?

After snooping around in settings and general places of the CRM 4 organization I saw that the attachment file size set in CRM 4 was 0, which in the picture below is set to 5 MB (I don't have any english CRM 4.0 available at the moment, sorry). This might mean that it has no max file size in CRM 4 since it obviously had file attached to emails however the setting seems to have a different meaning in CRM 2011. I set the max file size to 36 MB and took a new backup of the organization database, moved it to the CRM 2011 server and did an import.

Bingo. The upgrade went smooth and I had an upgraded organization that I was able to log in to. I find it a bit odd that this haven't happened to anyone blogging before me though

Please let me know if this has helped you, it would be nice to know I'm not alone :)

Rickard Norström
Developer at CRM-Konsulterna