October 12, 2012

TypeScript CRM 2011 client scripting definition file

CodePlex project page

Last week Microsoft went public with a JavaScript super-set language called TypeScript. The idea behind this language was to keep it compatible with JavaScript (all JavaScript code is TypeScript code) and add a few features which make it easier to manage large code bases.
This features include compile time type checking and well known OOP structures like classes, interfaces and modules. OOP structures were possible to emulate in JavaScript but required the developer to write code that wasn't very easy to read and understand.

Off course TypeScript code is not understood by browsers. The code you write in TypeScript is compiled to pure JavaScript using the type script compiler (tsc). You then reference that JavaScript in you're web pages. The compiler tries to keep the structure of the generated JavaScript code as close to the original TypeScript code as possible, so it's easy to debug.

In one sentence TypeScript makes JavaScript easier to write, maintain and safer.

The TypeScript team also created a plugin for Visual Studio 2012 that provides syntax highlighting, automatic background compiling and more importantly IntelliSense for TypeScript code. In order to use that feature for existing JavaScript code it is required to create a definition file (something like header files in C/C++). Because I'm mainly a Dynamics CRM developer I thought it would be worthwhile to create such a definition file for Dynamics CRM 2011 client scripting - the Xrm.Page JavaScript library.

Simple manual (if you already have TypeScript installed):
1. Download the Xrm2011.d.ts file from the link above.
2. Add it to your project.
3. In your TypeScript code reference the definition file by adding
/// <reference path="Xrm2011.d.ts" />
on top of the file.

Advanced manual (if you don't have TypeScript installed):
1. Download & install the TypeScript plugin from here.
2. Optionally download  & install the Web Essentials 2012 extension for Visual Studio 2012 for improved code handling.
3. Proceed with the Simple Manual

Why should I use TypeScript instead plain JavaScript?
The simple answer is that it makes coding much easier and less error prone. Please look at the following examples:
Design time type information

IntelliSense code completion

Design time check

If you see any errors or possibilities to improve the definition file, please write a comment.

October 8, 2012

Dynamic CRM + IE 10. Scrollbar position indicator barely visible

When I started working on Windows 8 right after the RTM release for partners I noticed an annoying issue. The scrollbar position indicators are barely visible. Maybe my monitor isn’t a professional Eizo, but I didn’t have this issues in previous versions of IE.

Look at this screenshot:
The color difference between the background of the scrollbar and the position indicator is very small. You have to really concentrate to see where it is.

Look at the close up:

image                          image

On the left the original, on the right with marked position of indicator. Doesn’t look very clear, does it?

The colors are:

Indicator: #E9EDF1

If someone knows a good solution, please post it in the comments. It’s a minor issue, but quite annoying.

August 10, 2012

Mapping SkyDrive, DropBox etc. folder to drive

This post is not related to MS CRM in any way, but it might come handy so I thought it’s worth sharing.

When installing cloud based storage like SkyDrive or DropBox you get a nice link in the Favorites section of Windows Explorer. Something like this:

This works very nice until the application shows you the “modern” save or open file dialog.

But what happens if an application is “legacy” or for some different reasons (I’m guessing Java) is using the older versions of the dialogs. You get something like this (example is from Adobe Reader X):

Navigating to your cloud based storage gets a little annoying. You have to click [Computer], [C],  [Users], [USER_NAME], [SkyDrive]. That’s 5 clicks just to get to the stupid folder. Someone could say that you only need to type in "%UserProfile%\SkyDrive, but lets be honest – that’s not something most of us think of in such situations (also moving the hand away from the mouse in order to type is quite annoying Smile ).

Wouldn’t it be nice to be able to map such folders to a drive letter? That way it’s only 2 clicks away.

The solution is quite easy – a windows command called subst. The syntax is as follows:
C:\Users\kowgli>subst /?
Associates a path with a drive letter.

SUBST [drive1: [drive2:]path]
SUBST drive1: /D

  drive1:        Specifies a virtual drive to which you want to assign a path.
  [drive2:]path  Specifies a physical drive and path you want to assign to
                 a virtual drive.
  /D             Deletes a substituted (virtual) drive.

Type SUBST with no parameters to display a list of current virtual drives.

So in my case just typing in subst Z: C:\Users\kowgli\SkyDrive almost solves the problem. The problem is this is not persistent across system reboots. In order to overcome this one of the simple solutions is to ensure the command gets executed each time the system start – read HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run


Adding the command to that registry area solves the problem. And now our folder is permanently mapped to a drive, which saves us 3 clicks a couple of times per day Open-mouthed smile

I know for some people this problem is trivial, but still … I thought it would be nice to share.


August 9, 2012

CRM 2011 plugin registration error “Inheritance security rules violated by type”.

When trying to register a plugin using an external dll ILMerged into it I came across the following error:

Unhandled Exception: System.TypeLoadException: Inheritance security rules violated by type: 'XXX.YYY.ZZZ.Plugins.ABC'. Derived types must either match the security accessibility of the base type or be less accessible.
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()

I remembered I had this issue before. The reason is that some legacy external libraries don’t follow .NET 4.0 security rules. The solution it actually quite simple – revert back to .NET 2.0 security. Simply add the following attribute anywhere inside you’re code (after the using statements):

[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]

July 31, 2012

CrmSvcUtil error - Exiting program with exception: The parameter is incorrect.

When trying to run the proxy generation tool after getting back from vacation I got the following error:
Exiting program with exception: The parameter is incorrect.


Simple solution – delete LiveDevice.xml file from %UserProfile%\LiveDeviceID

June 18, 2012

SSRS Division Helper App. Avoid errors in division result. (SQL Server Reporting Services)

A quite common issue in SSRS is getting properly displayed values when dividing 2 numbers. When the denominator is equal to 0 or NULL you get an ugly looking error or “Infinity” in the field. Not really what the customer would like to see.
A well known solution is when dividing A / B to do something like this:
= IIF(  IsNothing( B )
        OR B = 0,
        IIF( IsNothing( B )
            OR B = 0,

Writing this each and every time gets a little annoying. With the not so good code editor in BIDS when we have complex expressions instead of “A” and “B” it can actually be very frustrating and unnecessarily time consuming.
Having to do this over and over again I made a small and very simple tool I would like to share.
All you need to do is put the required values in the top and bottom. Click [Generate] and copy the result.
It saves some time and I hope someone finds it useful.
Download from here.
Source (VS 2010)

June 1, 2012

CRM Online Reports – visible previously internal parameters not showing up

Simple use case – I wanted to update a existing report setting a couple of report parameters to visible, which were previously set to internal. It showed up nicely in Visual Studio but although I updated the report a couple of times in CRM Online the report parameters were still not visible. I made sure the report itself was actually updated by adding some dummy text to it, but the parameters stayed hidden. It looked like the report parameter settings in SSRS weren’t really refreshing during the update.
The solution I found was actually quite simple. I deleted the report and uploaded it once again. Then the report parameters showed up nicely. It’s not rocked science but might come in handy for someone.