Bricking your CRM Forms, the ultimate guide

Posted: Monday, 20 October 2014 20:22 UTC in

Loader

The other day I completely bricked a form in Dynamics CRM. The form would just have the command bar and loader up, but nothing happen. This was in a custom entity we use for some settings, and I had a text field which was a template text for SMS sending. This text also had a few template codes that could be used. So in an attempt to be helpful. I added the available template codes in the description for the field. This way I thought it was easy for the user generating this templates to see what template codes that is available in the tool tip.

I had chosen a template format like {{contactname}}, and then I would replace this with the name of the contact when we were sending the SMS. The problem is that this is a pretty widely used format, and CRM uses JsRender, which uses this kind of format as well.

It also took some time to figure out what was wrong, because only Internet Explorer showed something in the console. And IE, was sadly in this case, not the first browser I tried. But when I did try IE, it gave me the error message below, and I immediately understood what had gone wrong.


JsRender Error: Syntax error
Unmatched or missing tag: "{{/contactname}}" in template

Field metadata

So by removing these template codes from the description on the field and publishing again everything was working as expected. I tried using HTML escape characters for the curly braces, but they was only showed as they are typed in. So as far as I know, there is no way to show template codes as these ones in the tool tip.

There is no problem storing these kind of templates in the field itself, but do not put it in the description of the field. There is also no problem storing single curly brackets in the description field either, just stay away from the double.


Hiding menu when printing in Dynamics CRM

Posted: Thursday, 18 September 2014 20:45 UTC in

Recently I had a client requirement that involved printing of CRM pages that contained web resources. The standard print functionality in Dynamics CRM only supports printing static content, so some web resources used on the page being printed was omitted. The user wanted to use the browsers print capabilities and it all worked great, except that the Dynamics CRM header was included on the top.

Print preview showing CRM menu

As you can see from the picture above, the menu from CRM on the top of the page, taking up some much needed space from other content.

The solution in our case was to do a little unsupported change by injecting some CSS in the page with JavaScript. You will only see this change when printing because of the media in the CSS is set to print.

$('head').append('<style>@media print { #crmMasthead, #crmTopBar {display: none !important;} #crmContentPanel {top: 0 !important;}}</style>');

As you can see below, the menu is now gone and we get some extra space on each page when printing.

Print preview showing page without CRM menu


New blog

Posted: Sunday, 07 September 2014 21:01 UTC in

I have planned for a long time now to change blog platform, this weekend I finally got around to it. My choice for blog platform is Jekyll and Jekyll bootstrap. The blog is now hosted on GitHub pages. I have changed the default design form Jekyll bootstrap a bit, but it is still pretty plain and I guess that reflects my design skills :)

Now I just have to start blogging on a more regular basis.


Web Resource Utility and CRM with Office 365

Posted: Tuesday, 16 July 2013 22:00 UTC in

If you wish to use the Web Resource Utility that comes with CRM 2011 SDK on an CRM Online organization from Office 365, you will not be able to connect to the discovery service.

When you type in your credentials and server address you will get the error message shown below.

Error message

This is because the Web Resource Utility uses

https://dev.[address_typed_in]/XRMServices/2011/Discovery.svc

That is correct for CRM Online as the discovery service, but not when you have CRM from Office 365. Office 365 instances of CRM uses disco insted of dev in the URL. So a correct URL for a CRM Online from Office 365 is

https://disco.[address_typed_in]/XRMServices/2011/Discovery.svc

For more info on the differnet discovery services see MSDN

Luckily there is an easy fix to the problem. In the method GetServerConfiguraton in the class ConsolelessServerConnection we have to change the DiscoveryUri.

Open the file and simply change the line

config.DiscoveryUri = new Uri(String.Format("https://dev.{0}/XRMServices/2011/Discovery.svc", config.ServerAddress));

to

config.DiscoveryUri = new Uri(String.Format("https://{0}/XRMServices/2011/Discovery.svc", config.ServerAddress));

After this change you will have to specify dev/disco part to use the tool, but it will work for both “regular” CRM Online and CRM Online from Office 365.

Connection window


How to install packages when NuGet is down

Posted: Saturday, 17 March 2012 21:33 UTC in

Sometime during the 9th of March NuGet.org went down. This turned out to last for a while and a lot of people on twitter told their stories how builds were breaking and how they did not get to download packages. For me, I actually noticed how often I use NuGet and how annoying it is not having a backup plan.

If you wonder why NuGet was down, you can read about it on their blog

Thru twitter I soon realized that I could add my NuGet cache as package feed, this was a great way to use all the packages I usually add to my projects. Unfortunately I had not used the package I needed on that computer before, so I was not able to install the package. But nevertheless I will let you know how you add your NuGet cache as a package feed.

Package manager

It is a pretty easy job to add new feeds to your NuGet package manager console. When you are in the package manager console, click on the “Package Manager Settings” button, marked with red circle in this picture. There is also possible to go on visual studio tools menu and options. Here you find a “Package Manager” node witch is the same place this button goes to or you can go on the tools menu – Library Package Manager – Package Manager Settings.

On the Package Manager Settings page, go to the Package Sources node. Her you see the feeds available to use thru NuGet. Now I am adding a new feed called Local NuGet Cache, and in the source I use C:\Users<LoggedOnUser>\AppData\Local\NuGet\Cache which points to my NuGet cache.

Package manager settings

Now I have this Local NuGet Cache that I created as a option in my Package Manager Console and can use it just as I would use the official NuGet feed.

Package manager feeds

So my backup strategy now is that I put my Local NuGet Cache and my public MyGet feed as alternative feeds in Visual Studio. So if NuGet will go down again for any reason I have some chances to get my most used packages still. If it is a package I have used on that particular computer before, it will be in my local NuGet cache. If it is not a package I have used before, hopefully I have added it to my MyGet feed so it is still available to me.

If you wonder what www.myget.org is, it is a site where you can create your own NuGet feed with packages from NuGet or any other package you might have. It is easy to use, works great and it is free if you choose the public or community feed, private feeds are not free.


About Sebastian

Sebastian Holager

Sebastian Holager is a developer working at a CRM Norge in Oslo, Norway. At day time hacking away on Dynamcs CRM, C# and JavaScript. While at night playing around with other programming languages, reading and watching football.

Follow me on twitter