How to cope when you are out of your Developer comfort zone

Don’t be afraid to say you don’t know something, you will always know less than there is to know. All you can do is to keep learning every day – Hosk

Experience is doing something new, making mistakes and not repeating those mistakes next time you do it – Hosk


When you get kicked out of your  comfort zone.  calm down, break the problem down, list what you need to do and don’t breakdown. Hosk

I was reading the well-written article about being a new developer

As a new developer

It neatly sums the fears of new developers trying to get started with development with only miniscle knowledge of development, surrounded by people who have been developming for years.

How the Heck am I going to do that?

I tweeted this and got a good response from CRM MVP Jamie Miley (see what happens if you stick at it kids)

how the heck

It got me thinking, there are times and situations when suddenly you get kicked well and truly out of your comfort zone

This could happen in a number of scenarios, some good, some bad and some scenarios life throws up just for the hell of it.

  • Promotion and new responsibilities
  • a new job/role
  • A developers leaves and you are parachuted into the project
  • working with new software/programming language

So how do you cope when you are out of your comfort zone

Step one – DON’T PANIC

Calm down, big breaths, it’s time to think logically.  When you are out of your comfort zone, you initial response is


Similar to going somewhere you have never been before, everything seem unusual and strange and in your mind the geography can seem endless because you don’t have concepts of distance of landmarks.

After you have wandered around a town for some time, it shrinks in size as the unknown area slowly becomes recognisable and manageable.

How do you eat an elephant?

You should see all problems as elephants you need to eat?

Most people see an elephant and think, it’s impossible to eat an elephant but this is because you are letting the problem (eating the elephant) overwealm you.  You need to break it down into eating the elephants ear or eating a bit of the elephants ear.

The answer to how you eat an elephant is, one bite at a time.

Don’t listen to your fears

This is similar to doing development in a computer language  or types of customizations you haven’t done before.  You usually have someone asking you for an estimate of how long something is going to take but how do you know you have never done it before.  You start to panic, you roughly think it would take this long but what if it’s tricky, WHAT IF I CANT GET IT TO WORK EVER!!!!

The devil who was snoozing on your left shoulder, cackles in delight and starts generating worst case scenarios, which no doubt involve you being sacked and shamed, being made to wear a billboard round town saying “I couldn’t code a WCF web service to interact with CRM”.

Don’t visualise all the things which can wrong, instead focus on this being a brilliant opportunity to learn new skills and show how capable you are.

Difficult tasks are solutions you haven’t yet created

Step two –  continue to calm down and engage brain

Calm down.  What you have to do is get the facts clear, work out what you know and then make a plan.

Just like writing code you need to simplify the problem and remove complexity 

  • What do you know about the problem?
  • What needs to be done?
  • How can it be done?
  • Questions/problems about the requirements and the solution

The different zones of uncomfortable

Here are some of the common tasks you might not have done before

  • Designing a solution
  • Creating new functionality/customization you haven’t done before
  • Integrating with 3rd party software
  • writing a WCF webservice
  • Using new software
  • Using a new coding language
  • Estimating a solution
  • setting up/installing software
  • Impossible Deadline

General Advice

Before I go into detail on some of the scenario’s above, I will go over some generic advice for surviving CRM development when you doing something out of your comfort zone.

Don’t panic

The don’t panic advice can be used in most scenarios.  Remember you are a skilled individual who has done similar pieces of development.

  • Keep calm
  • Work out what needs to be done
  • Split up the tasks into small parts
  • evaluate any potential risks
  • Ask advice from your peers and colleagues

Don’t be overwhelmed

At the start of a piece of development there is an initial moment where you think

How the heck am I going to do this, I have never done this before I don’t know how

Go back to the don’t panic advice and remember you have done big pieces of development before and if you haven’t, well there is always a first time.

A big piece of development is just lots of small pieces of development stuck together.

Don’t sit and suffer in silence

If you can’t do something and you have tried breaking it down but still don’t know where to start then it’s time to ask someone to point you in the right direction.

All Developers have been in the same situation as you are in right now at some point.

It’s time to get up from your seat and get some help.  Remember the task here is for the development to get done

If you can’t do it, speak up sooner rather than later

If you really can’t do the development then you need to raise this as soon as possible and someone who can do it can be resourced to do it.

It may be embarrassing at the time but your employer/boss will be grateful you raised it with enough time to get someone else to do it.

You can learn how to do it by seeing how the developer did it, maybe even working with them.

Afterwards you can go away and research the area yourself, so next time you will be able to do it.

Designing a Solution

Designing/architecting a solution can be daunting if you haven’t done it before.   What you need to remember is you could have done most of it, if you were made to but usually the Solutions architect does it.

The first task is to make sure all the requirements have been gathered and then study these carefully to see if you can come up with any questions.  The reason it’s important to make sure you capture all the requirements it’s easier to change a solution design than change a solution design and code.

When gathering requirements for CRM projects, you often do what’s known as Gap fit analysis

Gap fit analysis is where you compare the out of the box functionality in CRM with the requirements, working out what you can do with default CRM and what will be a customization

When designing a CRM solution try and break it down into smaller parts and break down these parts into the development you need to do to create the functionality.

When developing a CRM solution break the requirements down into separate user roles to help you understand how different users will use the system, what functionality each different user role need.

Create entity diagrams and flow diagrams to help you understand the requirement and your proposed solution design.

It’s a good idea to get someone to check your design, they will be able to find obvious problems and make suggestions.

Creating new functionality/customization you haven’t done before

Creating a customization type for the first time could be

  • Plugin
  • Custom workflow
  • Dialog
  • Action
  • Javascript

The first task is to find a working example of the customization, often you will be able to find an example of the customization inside the CRM project you are working on done by another developer.

If you cannot find any examples then you should search the internet or check the CRM SDK for some sample code.  You can also search the Hosk CRM blog which has lots of examples of CRM customization.

Once you see an example it’s easier to understand how it works and modify it for your needs.

Start simple and get the basic example of the customization working and then add your requirements.

Integrating with 3rd party software

This can be very tricky and some 3rd party software can have a complete lack of usable documentation.

One risk with using 3rd party software is finding out the limitations and quirks of the 3rd party software.

Writing a WCF web service

When writing working with CRM you will often need to integrate CRM with other systems and software a customer is using.

Many times you will need to create a WCF web service.

This isn’t any easy task and if you have never done it before you will have to learn quickly.  There are lots of good WCF tutorials on the internet and you will need to find one you can understand.  The other tricky part of writing a WCF tutorial is deploying it.

I have written a little bit about a WCF service and there are some good tutorials at the end

WCF with no service xml or endpoints? What is this magic?

Estimating a solution

Estimating is one of the scariest tasks a CRM developer can be asked to do.  The weight of the financial consequences of your estimate can be a worry.

As always keep calm, break down the development into small tasks and then estimate those tasks.

If their parts of the development you haven’t done before or parts you feel are risky then add some more time to the estimate.

Add all the tasks and estimates into an excel spreadsheet so you can justify your the amount of development time if you need to.

Breaking down the development will give you confidence in your estimate.

Configuring or installing software

There are lots of different pieces of software to install and configure with CRM Email router, Outlook

  • Email router
  • Outlook add in
  • CRM server
  • SQL Server
  • SSRS reporting server

There is some great documentation about installing and setting up CRM software and one of the key parts to installing/configuring is making sure the server meets the prerequisite requirements.

Know what service user accounts you will be using in your install and the privileges these will need, often you will need a domain admin to create the service accounts and this can take a few days with some IT departments.

Another tip is to download any software and prerequisite software you might need because a lot of servers will not have internet access.

Back up everything before you start

In most cases it will be going through and pressing next a lot of times.

Impossible Deadline

Customers will sometimes press the panic button and need some development/CRM project urgently and will insist on impossible project deadline.

I have written here why this isn’t a good idea

Why rushed projects/code doesn’t save time and reduces quality

Raise your objections about the rushed deadline and lower expectations it might not be possible.  Do your best and if you have to work extra hours/overtime make sure you get this time back and bring it up in your yearly review.


How to prepare for these situations

There will come a situation which you will be doing some CRM development for the first time but you can prepare for some of this situations.

Solutions architect

The best way to prepare designing CRM solutions is to design CRM solutions.  I appreciate the advice is clearly in the category of “bleedin obvious”.

The problems you find when designing a solution only occur when you are deep into the design and only when you really look at a design will potential problems become apparant.  In similar way to have theoretical knowledge of writing CRM plugins, custom workflows or a WCF service will help you, until you have created a CRM customization you won’t have experienced all the problems which occur when trying to get code to work.

When writing code, customizations, functionality, software products you haven’t used before you will create a lot of errors which you overcome by reading the documentation and trying different things.

In the blog post-Why .Net developers struggle with CRM development I go through the knowledge you need to get a plugin working.

Designing a CRM solution has a similar learning curve (probably most activities do) and you will only encounter and overcome these problems by experiencing them.  To experience the problems you have to go through the process of designing a CRM solution as if it was real project otherwise you won’t do it properly and not worry about the solution not working.

A good way to practice is to get the requirements for projects your company has done and design a CRM solution for it.  You can then compare your solution with the solution that was implemented.  Once you have your design you can ask a solutions architect or a senior developer to look at your CRM solution and give feedback.  If the person who designed the implemented CRM solution is still at the company you can ask him about the implemented solution.


Estimating a solution

Similar to designing a CRM solution, the best way to practise estimating development is to practise estimating development.

Go through previous CRM developments requirements and practise estimating and then comparing your estimate to the estimate given.  You can ask the CRM developer involved in the original estimate to explain his estimate and ask other CRM developers for advice.

Configuring or installing software

Practice installing/configuring CRM software before you need to do it on a customer project.  You can ask the IT department if there are any virtual machines you can practise installing software on or you can get your own virtual machine and install CRM with a demo license.

Creating new functionality/customization you haven’t done before

Any CRM development you haven’t done before you should get some experience doing yourself with a CRM trial version.

Once you have done it once you will have working version to modify and the experience of getting it working.


One of the hardest parts of CRM development is doing something for the first time and the best way to prepare is to practise.  Practising development, installing software, designing solutions, estimating etc will allow you to go through the process without the pressure of doing the process for a customer.

When delivering a CRM development activity for a customer there is pressure to produce the development activity in good time and to a high standard.  When you practise the development activity on your own these pressures don’t exist and you can concentrate on the activity.


Why you should write code and customizations like a boy scout

As the cost in time and effort of refactoring goes up, developers will add more bad code because it’s easier and quicker.  The result is the bad code in a project is like a snowball being rolled in snow, it just gets bigger and bigger – Hosk

I was reading an article which had the concept of the boy scout rule  boy scout rule, it’s from the pragmatic craftsman and I would recommend the excellent book  The Pragmatic Programmer

If you haven’t read it yet, I recommend you, it will help anyone who has to write any code or is doing any development.

Development and the boy scout rule

Boy scouts have a rule

Leave the campground cleaner than you found it.”

The other makes this point about code

“the code cleaner than we found it.”

What does this mean

The meaning of the quote with regards to code, is to encourage coders not to add bad code/quick fix code.

I would classify quick fix code as pushing and poking in some code to fix a problem, which adds to the complexity of the code rather than simplifies it.  It might fix the problem but if the code is poorly written and structured it is moving the code towards spaghetti code

If you think about a teenager who keeps putting off cleaning their room by hiding dirty clothes under pillows, shuffling things in cupboards.  If the teenager keeps doing this in the end the room turns into a big mess.  This is ok until the teenager wants to find something, they can’t because stuff is everywhere, there is no order and it’s hard to work out where to look.

Instead of cleaning and tidying up the room, developers when adding bug fixes, keep placing quick fix statements, which over time slowly creates bigger and bigger methods, code complexity increases.  The code because tightly coupled and starts to get more like spaghetti (e.g. code is linked together),  maintaining, enhancing and debugging the code becomes difficult.

This is where the boy scout rule should come into play

Leave the camp ground cleaner than you found it.”

If you adhere to the rule above it would mean instead of adding quick fix code, you add the code properly which may mean refactoring classes and methods and keeping the code.  It will probably take longer in the short term but it will keep the code well structured, simple and readable (why code readability is important)

Code which isn’t readable (the code which gets the quick fixes) is

  • Difficult to understand
  • Longer to debug
  • hard to maintain
  • tricky to extend

The codes growing method/class size, increased coupling and  added complexity results in the code taking more time and resources to maintain in the future.

When changing code you should focus on making it readable and adhering to good programming standards.

The benefits are

  • Removes duplicate code
  • Easy to understand
  • Consistent
  • Small methods which do one thing
  • Logically structured and designed

What I don’t like about the boy scout rule

The idea is great but when trying to explain this concept to other developers.  For developers/programmers to follow this rule it will result in them doing

  • Refactoring code
  • Writing better
  • Keeping to high standards
  • No quick bug fixes
  • Increased time and effort to change code
  • Increase in Testing

It’s the difference between quickly shoving some clothes in a draw and cleaning the whole room.  Interestingly outside of coding I am very messy person

Acting like a boy scout and follow their rules and tenants is not initially appealing to most developers, particularly if it’s going to take extra time and effort.

My point is it can be hard to persuade other developers to put this amount of effort in, even if they will benefit and save time in the long term.

How do we sell the long term benefit over a short term gain

Help your future self

What I try and do is explain to developers is this will save themselves time and effort in the future and will make their job a lot easier in the future.

If you wrote the code now, there is a good chance you will pulled back into bug fix, maintain and enhance it later on.  When you are working on a project full time, you have a great understanding of the project and you are in the project zone.

Being in the project zone means you understand the code AND all the business rules/business knowledge which goes with the project.  Like sportsman being in the zone doesn’t last and you move onto other projects (although sometimes it doesn’t seem like that).  Due to your extensive knowledge of the project, the business logic and the code you will be the prime candidate to fix any bugs which get raised.

The Messy Garden Shed

If you think of a project customizations like a garden shed.  If every time you use the lawn mower, spades, bird feed, kids toys you tidely place all the items back.  When you need to go into the garden shed a few weeks/months later you can easily find everything without having to remember where you last put things.

If you have a messy garden shed where everything is thrown into the shed and items are over and under each other.  To find the item you want you would have to try and remember what you used last (you might not have been the last user). If you can’t remember you can slowly start pulling things out, looking around.  With everything scattered around it’s difficult to know what’s in the shed, let alone where it might be.

It takes a lot longer to find things in the messy garden shed but if you went into the shed the day after you used the spade, you would have a good chance of knowing where you put it.

The messy garden needs you to remember where things are, this is similar to needing to understand the code and business logic in complex code solutions.

In six months plus time you won’t know the code and you definitely won’t remember the business rules and business logic.

So the code has to be as readable as possible and should not be complex

Scare them

You could try and scare the developers with this great quote

Why you can’t let standards drop

This is a great rule but I’m not sure how effective this would be at movitating people to tidy and refactor the code.  Unless you hired a violent psychopath to walk around the office once a month and maybe do a few code reviews.

Developers should have enough respect in their work to do this as a matter of course or to help themselves out if they have to fix the code later.


Go round the officing saying this to fellow developers at least once a day

Times may change but standards must remain

Enjoy your work and take pride in creating excellent simple code because as soon as you stop doing it, so will everyone else


Why .NET developers struggle with CRM Development

Experience is important for a CRM Developers. You have to learn how things don’t work first 🙂 no shortcuts

CRM Developers have to learn the mysterious ways of CRM development, they need to learn the the quirks and the way things work with Microsoft Dynamics CRM development.

Microsoft Dynamics CRM can be illogical but we are all used it to now.

If CRM was an animal I think it would be a cat, it’s unpreditable and sometimes very difficult to persuade it to do as you would like


This makes experience very important because to learn how things work, you have to go through the process of things not working (often in many different flavours of not working) before it works

There are some shortcuts but often you have to go through the painful process yourself.




When a CRM developer starts developing a plugin, he will learn the all the steps you need to take and the hoops you need to jump through

I went through some of the common problems in this blog but here is a quick recap

  • setup up CRM Developer toolkit
  • User has to be CRM Admin
  • Isolation mode? if none user has to be a deployment administrator
  • plugin needs to be signed
  • crmRegister file needs to be checked out

These are the simple things you need to do to create and register a plugin, that’s without even thinking about the code and if it works, testing, debugging etc.

CRM tools

There are lots of tools where you have to put the server, the CRM Discovery URL, the OganisationService url.

At first you guess what they are, fail a bunch of times until you knuckle down and find out where those urls are, what they do and why the tool needs them.

Use Microsoft Dynamics CRM services in code

Then one day you find they are hidden in CRM under settings, developer resources!

CRM 2011 – Discovery and organization service are held in settings

WHY .NET/C# struggle developing

Sometimes companies don’t want to pay for CRM developer or have C# resources which they think they will use to do some CRM plugin customization.

This theory seems like a sound idea, the actual C# code in a plugin is usually quite small and not overly complex but for a C# Developer with no CRM experience it’s a total nightmare

C# developers with no Microsoft Dynamics CRM development experience don’t understand how data in the CRM website is structured in SQL Server database

  • How CRM works with customizations
  • The different types of customizations to choose from, without this knowledge how do you pick the correct customization type.
  • How do I create a plugin
  • How do you register a plugin – common plugin errors
  • How do I write a query to retrieve related records in CRM

Whilst the C# developer goes through learning how things don’t work, it takes the developer a lot longer to write the plugin (if they manage it)

The kicker is if they don’t do constant CRM Development, they will forgot all the lessons they learnt from the work above, slide down the snake and have to learn all again next time.

Hands on experience is vital

The reason hand’s on experience is vital for CRM developers is when a CRM developer is creating customizations and code to work, they will have to overcome a lot of situations where the code isn’t compiling, it isn’t working.  During this minor setbacks you the CRM developers will read blogs, the SDK and work out why it doesn’t work.

The CRM developer will end up with a working customization, e.g. plugin but will also have a better understanding of creating CRM customizations and a more in depth knowledge of how the CRM customization works.

You cannot get this knowledge and experience through reading about CRM customizations like plugins, custom workflows etc.

Creating the customization gives you a deeper knowledge of CRM development because reading about CRM development won’t tell you about what doesn’t work.

If you think about knowledge as 3 dimensional object, reading about CRM Development gives you one view of the object.  Getting it working and overcoming the errors during this process gives you a different view of the object.

Experience is earned

When you start creating CRM plugins, worfklows and other customizations you will run into lots of puzzling problems.  Slowly one by one you will overcome the initial problems and find more intricate problems, which usually move towards logical problems and quirks particular to CRM development.


The point I am trying to make is CRM Developers learn CRM development by overcoming errors and problems and learning not to make them in the future.

The CRM developer will make less errors whilst creating their CRM customizations (plugins, custom workflows, Javascript, etc), this gives them time to focus on refactoring their code, new functionality, testing, writing better structured code (which is readable).  Their understanding of the underlying CRM structure grows and becomes more in depth.

I view CRM developer progression similar to driving a car.  When you start out driving a car, everything is difficult and you have to think and remind yourself to do these tasks

  • Putting on your seatbelt
  • Seat right positioned correctly
  • Constantly checking all of your mirrors
  • Indicating at the correct time
  • Changing gears and being in the right gear
  • Braking distance
  • Estimate distance
  • Monitoring speed (and not speeding)
  • Understanding what the road signs mean

The driver slowly gets more experienced and begins to do many of the those tasks without thinking, this gives them time to focus on other parts of driving, like not crashing and watching out for idiots on the road.  Driving on the motorway, driving in the rain and snow are all experiences built up over time.  Slowly the driver will become better (hopefully).

The point is you can’t read how to become a better driver, you have to apply the knowledge and experience it yourself.  The same is true about CRM development.

The only way to speed up experience is to do some CRM development outside of work.


Mark McGookin had been working on some CRM development and getting IFrame errors.  Errors messages rarely point to the actual problem as most CRM developer find out.  Error messages are a sign something went wrong and you need to do some detective work to find the root cause.  You can do this by checking your logging, Plugin Trace files, Event Viewer on the CRM server or by debugging the customization.


Mark was trying to use Document Management in his code, eventually he found the iFrame error was actually occurring because the SP Root location was null.

crm dev experience


Experienced CRM developers make less errors because they have learnt to stop making these errors through experience and bug fixing those problems.

Due to the experience and knowledge gained through experience and reading they will make better choices about what customizations work well in certain scenarios

One the key roles experience developers have is advising and peer reviewing less experienced developers.  Finding problems and bugs earlier in the process can save you hours if those same bugs are found when the CRM customization has gone to the customer.


What is a Gateway pattern?

I’m not talking about a Gateway to another dimension (as pictured above), I know what they are and I can use them without any problems.  I’m talking about the design pattern Gateway, it suddenly popped up in a project and I wasn’t sure what the heck it was.

There can be occasions when working with developers, they will start using some terminology or design pattern which you either don’t know or can’t remember.

This can be a bit awkward because you can feel like a bit of an idiot and the other person was talking about it like it’s something everyone knows.

  • If knowledge is power, I view a lack of knowledge as an opportunity to learn and another step towards becoming all powerful (MWHHAHAHAHAAHAAA – evil laugh)
  • Don’t be embarrassed about not knowing something, it is in fact impossible to know everything.
  • Grab the opportunity to learn something from someone who knows about it.  They won’t look down on you and 99 percent of people will be happy to help and explain it to you (because it makes them feel great being the teacher/master).
  • It’s often easier to understand from a person rather than reading it from a book/article because you can ask questions and clarify areas of confusion
  • Always try to keep learning and if you don’t understand something, don’t sit quietly, hiding in the corner, be proactive and learn that piece of information, you never know when it may come in useful in the future (when you really need it).

I am reading Josh Waizkins book, the art of learning

He focuses not on winning/losing but always learning from both, in some ways this is similar to not knowing something or knowing a certain piece of knowledge.

  • Knowing – you can explain to someone else plus there is usually more to learn
  • Not knowing – don’t be embarrassed because you can start learning about the subject and move it from being a potential weakness into a potential strength.

Constant Learning

The life of a developer should be one of constant learning because a developer’s core skills/knowledge are in constant danger of becoming out of date as new languages/functionality constantly emerge.  To combat this developer should always be learning and building on their knowledge and skills.  I believe this is an attitude/philosphy of good developers, whilst the average/bad developers have no interest in learning (and complain about doing so) until one day the company lets them go because their programming skills are not useful in the new projects.

In CRM terms you can view this as new functionality, new releases, new Javascript frameworks, 3rd party applications integrating with CRM.  You need to try to keep up, so you have some knowledge before you need to use it in a live project.

Knowledge is incremental

I believe knowledge is incremental, you keep building on previous knowledge and you get a better understanding of new coding functionality and a more in depth understanding of functionality/code you already new about (but now armed with more knowledge you can see things you hadn’t noticed before)

Back To Gateways

The gateway pattern is a lot simpler than it sounds, but sometimes it takes great skill to describe things simply and concisely, which is why I won’t try to do that and will pass on that task.

Microsoft has a great description of the Gateway pattern, which you can find in full here

Gateway component that abstracts the access to the external resource. The gateway presents a single interface to the integrated applications while hiding the external resource interface. In addition, the gateway encapsulates any protocol translation that may be necessary to communicate with the external resource.
This diagram explains how the Gateway pattern works probably better than the description
You can see the Gateway pattern creates a single source of access (a single interface), behind it, it can offer lots of different methods.
You could consider paying for an item on amazon/ebay. The seller is only concerned with being paid but behind the payment there are lots of different methods of paying like credit card, debit card, paypal etc.

CRM and Gateway

In the CRM project I was working on, there were lots of Gateway classes in the plugin projects.

I found this confusing to begin with, the primary reason being I wasn’t sure what the Gateway design pattern was and my business knowledge of the project was not in depth.   It turned out the Gateway classes in this project were used to store mainly Linq queries for various entities used in the plugins.

This particular project used Linq queries, but in the Gateway classes it could have used QueryExpression it wouldn’t have mattered because the plugin code initiated the Gateway class and the various methods used to retrieve data.

The benefit of decoupling CRM queries into separate classes is you can reuse those classes in various plugins and test them without having to test the plugin code.

What is TypeScript and how does it work with CRM 2011/2013

I prodded CRM MVP Dave Berry with a twitter stick, berating him to start blogging again, this is dangerous because he is a CRM Super Hero

You should read his CRM MVP Q&A, it’s very funny and interesting

Th reason I was prompting him because I was reminded of his great blog posts because I was reading a blog post from Guido Preite who wrote an excellent blog entry –  Entity.GetAttributeValue<T> and ActivityParty, This is a great blog post from Guido and I would recommend all CRM Developers to read it (and subscribe to his blog).

In the blog he links to a Dave Berry blog post explaining Entity.GetAttributeValue.

Entity.GetAttributeValue Explained

This prompted me to tweet Dave Berry and he said he was doing some work on TypeScript and CRM.

What is TypeScript

Lets start with Wiki Definition

TypeScript is a free and open source programming language developed and maintained byMicrosoft. It is a strict superset of JavaScript, and adds optional static typing and class-basedobject-oriented programming to the language. Anders Hejlsberg, lead architect of C# and creator of Delphi and Turbo Pascal, has worked on the development of TypeScript.[1][2][3][4]

TypeScript is designed for development of large applications and transcompiles to JavaScript.[5]As TypeScript is a superset of JavaScript, any existing JavaScript programs are also valid TypeScript programs.


Stackoverflow has a good discussion

Typescript is a superset of Javascript which primarily provides static typing, classes and interfaces. One of the big benefits is to enable IDEs to provide a richer environment for spotting common errors as you type the code.

It’s still early days, but to get an idea of what I mean, watch Microsoft’s introductory video on the language.

For a large Javascript project, adopting Typescript might result in more robust software, while still being deployable where a regular javascript application would run.

It is open source, but you only get the clever Intellisense as you type if you use Microsoft’s Visual Studio (also noted in blog post from Miguel de Icaza).


Typescript home

This site has a bunch of samples, handbook and tutorials and is probably a good place to start.

Good articles on TypeScript

Some great resources for learning type script

 TypeScript: First Impressions

Enhance Your JavaScript Investment with TypeScript

What is TypeScript

TypeScript: JavaScript Development at Application Scale

7 months


Hosk Thoughts on TypeScript

I will add I haven’t used TypeScript yet, so I’m just basing my thoughts on what I have read, whilst writing this article.  If you do want to get started using TypeScript with CRM, Dave’s article TypeScript, CRM 2011, and You is probably the best place to start.

As a Java developer and then C# I have often found JavaScript and it’s dynamic types confusing and dangerous.  It does have advantages like Using Dynamic Javascript.  Strong typing

The biggest problem I have is Javascript makes it hard to create classes and structure the code in logical and well thought out design.  The flip side of this it’s easy and tempting to right quick messy Javascript code which is a pain to debug and maintain later.  Javascript doesn’t offer much to the Developer with intellisense or code checking.  This means I can often publish code with syntax errors in it!!!

The first interesting point about TypeScript is it compiles the code to JavaScript, so the end product of your CRM development will be the same e.g. a javascript file.  You can almost think of it as the difference between writing early bound and late bound code.  The advantages of writing early bound plugin code, is the plugin code uses the entity classes and fields.  Early bound code has these advantages

  • Easy to read and understand
  • removes syntax errors
  • Casting and type errors are found at compile time (and not runtime by the customer)

TypeScript in my view is trying to do the same kind of standards and advantages to the JavaScript code as early bound code does to plugins.

One of the main advantages (in my opinion) is TypeScript makes it easy to create types, modules and interfaces in your code, which means the code will be more like the strong typing (C#) code.  This should make it easier for developers to create well structured code and less excuses for Developer to create hacky, messy Javascript.

Auto Complete/Intellisense improvements

Reading the page, another benefit is with strong typing (read this wiki article about strong and weak typing) is you can get visual studio tools/development tools to help with best practices, static checking and code re-factoring of the TypeScript code.  I understand this to mean it’s like writing plugins using early bound code, with Visual studio helping you easily select fields (defined in your entities file) and refactoring and check your code for best practices with tools like ReSharper and FXCop

The benefit of visual studio helping autocomplete all the Out of the box Javascript functions is probably worth it alone




TypeScript was created by Microsoft

Microsoft created TypeScript to help .NET developers create similar code in JavaScript as they create in .NET.


CRM and TypeScript

There isn’t currently lots of resources or examples of TypeScript and CRM, I’m not suprised by this because until Dave mentioned I hadn’t really heard much about it.

Before you start creating any TypeScript I think I would start with the article written by Dave Berry

TypeScript, CRM 2011, and You

The blog post was from May 2013, so it will be a bit out of date (I’m guessing) but Dave has put these advantages of learning TypeScript

  • Types!  (If that wasn’t the first thing on this list, I should be soundly questioned.)
  • Compiles to JavaScript by basically removing itself from the code, and applying some cohesive closure structures to the results.  (This is why all valid JavaScript is valid TypeScript.)
  • C#’s interface and inheritance model!  (Multiple inheritance isn’t supported, but multiple interfaces are.  My C++ days are calling, and I let it go to voicemail.  I’m ok with this model.)
  • Multiple method signatures!  (This doesn’t apply anything on the “compile” to JavaScript—yet—but makes the IDE experience nicer.)
  • Generics!  (…coming in TypeScript 0.9)


CRM 2013

There is a good CRM 2013 blog post (split in 2) on TypeScript, which is simple and straight forward and a great place to start learning to use TypeScript

TypeScript and Dynamics CRM 2013 – Part 1

TypeScript and Dynamics CRM 2013 – Part 2

The CRM2013 definition file is on GitHub (


CRM 2011

There are three blog posts I found on CRM 2011 and TypeScript

Using TypeScript for CRM 2011


TypeScript, CRM 2011, and You

To use TypeScript you need a definition file and for CRM 2011 you can find it

CRM 2011 TypeScript extension



Hopefully I will get a bit time to have a play with TypeScript myself, I love the idea of it and think it could a great tool to write JavasScript which would be easier to understand/maintain and with the improvements with intellisense would make less sytnax, complete waste of time type mistakes, which could save a bunch of wasted time publishing Javascript files.

This was my first look at TypeScript and the next step is to get my hands dirty and dive in.

If anyone else has any experience using TypeScript please leave a link to your experiences/blog post in the comments

12 Ways to become a better CRM Developer

Now and again I get asked how to become a better CRM Developer, so I thought I would create a blog to point people towards and here it is.

1.  Decide you want become a better Developer

Improving and becoming a better CRM Developer is a state of mind/attitude, you have to want to get better, you have to strive to be better every day.

It’s like trying to get someone to read a book you like, you can’t make them read that book no matter how good you say it is, it’s only when the person wants to read it.


2.  Make a plan

A plan is like a map, if you don’t use a map it’s very difficult to get to where you want to go.  A plan is the same for careers and learning skills, you need to identify the skills you want to learn and make a plan to learn them

What areas do you need to improve in?

  • Plugins
  • Javascript
  • CRM 2013 new features
  • CRM 2015 new features
  • WCF webservices
  • Dialogs
  • Certifications
  • programming
  • reports (Bids and SSRS)
  • Data import (Scribe, SSRS)

Make a plan to start learning and getting experience with the above areas.

3.  Read Blogs

I believe all CRM developers should have a selection of blogs on CRM.  These links have some great blogs

Top 25 Dynamics CRM Sites – featured on Dynamics 101

Blogs featured on Microsoft dynamics blog list

Twitter is also a great way to find interesting CRM blogs.

CRM blogs provide technical knowledge and examples of new functionality and CRM development usually written by a CRM expert.

4.  Write blog posts about CRM Development

A great way to learn CRM Development is to write blogs and teach others CRM functionality.  This will not only increase your profile and brand in the Microsoft Dynamics CRM community but you will also understand the functionality better by explaining it.

Clearly explaining how functionality and technical ideas will involve you understanding the topic in greater detail and analyising it before expressing those ideas on your blog.

As an added bonus you will easily be able to find your notes on the subject, I often search my blog solutions to problems and quite often find articles/solutions I forgotten I had written.

Writing about CRM Development reinforces the knowledge, increases understanding of what didn’t work and what did work.

5.  Create Customizations – Write Code

You cannot learn CRM development purely by reading, you have to get your hands dirty and do the development yourself.

One reason practical experience is so useful is getting things to work is a major hurdle in development and until you do you can’t be sure you can or how difficult it is.  The process of getting code to work is usually going through many iterations of the code not working and you learning from your mistakes until you get it working.

Understanding how code doesn’t work gives you a great understanding of how CRM code does work.

The experience of getting an example to work will give you confidence and a working example when it comes to using the functionality in a CRM project.

6.  Learn from your colleagues

All CRM developers have individual areas of expertise their colleagues do not have and you can learn new techniques and skills from your colleagues.   CRM Development and coding is a world where there are millions of classes, methods and functions which it’s impossible to know about all of them, good developers will sniff out the really useful ones but often someone will tell you a technique/method you have never heard of which could make your life loads easier.

You can learn from

  • Peer reviews
  • Reading code written by your colleagues
  • Talking about CRM development

7.  Never stop learning

Becoming a great CRM Developer is a journey which never ends.  There is always

  • New functionality to learn
  • Better techniques
  • New tools
  • New technologies
  • Teaching others
  • Learning from your mistakes
  • Learning from your successes
  • Loads of other things I haven’t mentioned or don’t even know about yet


8.  Stop to think – analyse what you have done

An important step in CRM Development is making sure you stop and think about the CRM development/customizations you have done.

A good time to think about things you have worked on is during a lunch time walk.  Think about how you could have done things differently, the good and bad points.

Analysing your development can help you identify weaknesses in your code and understand why.

For every bad line of code you avoid writing the increased chance of a good line of code taking its place.

Sometimes getting better is not making as many mistakes as the project before.

9.  Don’t take the easy option

If you want to get better you have to constantly push yourself to be a better CRM developer.  This means getting involved in difficult projects and tricky customizations.

Keep up to date with the new functionality in Microsoft Dynamics CRM and try to work on projects which are delivering the latest releases.

Don’t let your standards drop and don’t check in bad code with a promise to refactor it later.

10.  Create free tools – Give yourself a project

Not only will you create something useful for yourself and others, hopefully more useful than this

Hosk’s CRM 2013 Guid Getter

You will learn skills, overcome many problems, get some great experience and learn new skills.

If you are not sure what tool/solution to create then think if there are any things which could be automated in your company or if there something which could be automated or improved in CRM.

It could be Access Team template import/exporter to solve the problem I discussed in the blog post CRM 2013 – Why are access teams marooned?

11.  Read Books

When I say read books, I don’t mean just read CRM or Developer books but you should read all types of books.  Great ideas can come from all areas of life and reading books are a great way to switch off from CRM and focus on something different, you will get ideas/thoughts which will enable you too look at CRM from a different view point.

Some good developer books, which aren’t really about Development I talk about here

Recommended Reading for Developers

The coding horror list is a great list of books, most of them focus on people and processes rather than writing code, which is logical because you will spend as much time interacting with people as you will writing code

Coding Horror – Recommended Reading list for Developers

If you don’t like reading then I would suggest listening to some audio books during your commute or when you are doing the cleaning.

On a personal note, I love science fiction books and have been working my way through the SF Masterworks list

12.  Have other hobbies

Remember, there is more to life than CRM Development so make sure you are spending time with your family and loves ones and get yourself a hobby or a sport, you have to switch off and get your life in balance.


CRM development is great fun, don’t forget to enjoy yourself.






Do you fix or a restore a Confused CRM Database?

Very odd situation occurred recently and left the poor CRM database in a state of confusion.

it started yesterday when I was getting an invalidCastingException when a plugin was running.

Unexpected exception from plug-in (Execute):  System.InvalidCastException: Unable to cast object of type ‘Microsoft.Xrm.Sdk.Entity’ to type ‘ActivityParty’

I couldn’t fathom why I was getting this error because I could walk through the code in a console app, calling the same business logic/class. I could see the entities file and it had the ActivityParty included in it, what the heck was the problem

The error above was happening yesterday, I came in today thinking about the error and cause must be linked to the entities file because this is used when creating and using early bound classes.  If I refresh the entities.class it should work.



I had been running the crmsvcutil.exe but I hadn’t noticed it had been erroring, instead of refreshing the entities.class.

So today I started looking at the

I started when I was trying to build the early bound entities.class, I was getting an error


Exiting program with exception: Mapping failed for Microsoft.Crm.Metadata.EntityMetadata property Attributes with exception Microsoft.Crm.CrmException: Mapping failed for Microsoft.Crm.Metadata.AttributeMetadata property Description with exception System.ArgumentException: An item with the same key has already been added.

The only previous time I have seen duplicate, same key error is when you try and import a solution with a field which was deleted and recreated as a different type.

This error returns very little from the internet (never a good sign) but the one article I found which seemed to make sense was from CRM MVP David Jennaway
user had upgraded, the upgrade process had somehow created two metadata fields of the same type. It has an interesting script to find duplicates

Nothing is working

Developers can sometimes only access CRM from the SDK they forget to check things on the CRM front end e.g. the CRM Web application.

I went into CRM and found I couldn’t publish any customizations and in fact all the plugins were not working.

We quickly reached the opinion a server reboot might fix the problems and restarted it with the reason (Hosks big problem)

unfortunately this did not resolve the problem and what we think happened was CRM let us add two fields with the same name.  There were some modifications to one of the entities in the afternoon, which we think is probably the culprit

CRM had now decided to lock up good and proper, we could export any solutions to try and edit the

What to do next

It was a DEV solution were unmanaged.  This means deleting the solution won’t do anything to the customizations. If they were managed solutions deleting them would also remove the customizations (and the dodgy double field) but it would also remove all the data (hmm it might take a while to create/import all that data)

We couldn’t import a solution over the top, wait I will rephrase that, we could but importing solutions are an additive, which means they only add things, they will not remove them.

CRM 2013 – Understanding Solutions and how they work

Restore or Fix (Stick or Twist)

Sometimes you have to make a decision to rollback to a previous database backup.  When you add the time it would take to investigate and fix the current CRM solution/database compared to rolling back to a daily backup from yesterday or maybe the day before.

In this calculation you also need to think about how many people are working on the project because during investigation it means other developers had to stop.  We think we might have known the cause but fixing it looked like tampering with the database directly.  This isn’t a great solution because we might just be kicking the problems down the road because we couldn’t be sure (if we worked out how to fix the problem) when fixing the problem we were creating more problems which we would find later.

Sometimes it’s better to lose one day of customizations versus weeks/months of potentially corrupt customizations

This is also highlights the importance of checking in your code changes into source control.  Most of the changes I have made during the last couple of days are all held in source control, so I just need to redeploy.

Changes to CRM customizations are a bit more tricky e.g.

  • Entity changes
  • fields
  • views

These can only really be backed up by exporting the solutions they are held in, on a daily basis, although they are of course also backed up in the database itself.  It is possible to export solutions programatically, so you could create an application which you could setup to a windows daily task (although I haven’t yet seen anyone do this)

The morale of the story is, make sure you put your changes in source control because the server could get corrupted or your own computer could crash or get lost and then you could be in real trouble

picture confused from here

picture wall from here
stick or twist picture

Use GetValueOrDefault in early bound plugins and say goodbye to catching nulls

When writing plugin code CRM has a very frustrating feature which allows it’s fields to be null.  Note I said this was a feature not a bug 🙂

I believe this was was one of the main reasons in CRM 4 it had it’s own set of variables CrmDateTime, CrmDecimal, CrmFloat, CrmMoney, CrmNumber.  These could hold a null as well as value (I think, it has been a while since I did any CRM 4 development).

Where this really niggles me is when I can’t pass anearly bound field  into a method because the method takes a bool but the early bound field is a ?bool, which basically means it’s a bool that can be null.

So how do we code around this

Late bound

So in previous blog post I have talked about using Entity.GetAttributeValue instead of Entity.Contains

using GetAttributeValue is great because it means I could take all the entity.contains code below

if (entity.Contains("salutation"))
     title = ( string)entity.Attributes["salutation"];

The GetAttributeValue returns either a null or a default value.  This is great for boolsints etc because instead of null I now get false or 0;

here is the list of default values
Type Return
Numerical (int, decimal, double) 0
Boolean false
DateTime DateTime.MinValue
Guid Guid.Empty

For other variables it will return a null.

Early bound

What if you are using early bound classes and don’t want to add the potential risk of putting in syntax errors in your plugin code by using late bound code.

What are the benefits of early bound code

  • Readability
  • No Syntax errors at runtime
  • casting errors are found at compile time
  • Easier to read, debug, maintain and extend

The main reason I like early bound classes is because it’s easier to understand and I don’t have to keep looking up and typing the name of the CRM fields.  It also moves most of the errors into compile time (syntax and casting errors), which means it’s less likely these errors will get through to the customers.

GetValueOrDefault to the rescue

If you want to convert the an early bound field into simple attribute then you should use GetValueOrDefault, which

The reason it’s a good idea to use this is because if you casted it to a bool or int you are in danger of creating an error because you cannot set a bool to be null!

The GetValueOrDefault will return a value (the default value for the variable type) even when the HasValue for the field is false (e.g. it’s null). Using the GetValueOrDefault means you don’t catch the error but you do have to be prepared for receiving a default value and code with that in mind.

So here it is in action

if (entity.Contains("salutation"))
bool credit = entity. CreditOnHold.GetValueOrDefault ();
entity. CreditOnHold = true ; credit = entity. CreditOnHold.GetValueOrDefault ();



The MSDN article if you want more, to be honest there isn’t much more to say about it.

CRM 2011/CRM2013 – Investigating a casting error with ActivityParty

I was getting an odd error whilst casting a CRM dynamics spell, no it wasn’t a spell it was casting an ActivityParty to an Entity (although some people might say ActivityParty is rather magic or at least very complex)

Talking of bad casting, this would have been terrible

Burt Reynolds as Han Solo in Star Wars


Casting Error

error in getproduct Unable to cast object of type ‘Microsoft.Xrm.Sdk.Entity’ to type ‘Hosk.Dynamics.Entities.ActivityParty‘.

It was on a plugin on the ServiceAppointment entity.  What I was trying to do, is when the user updated the ServiceAppointment Entity.  I would check the resources (which can either be a user or equipment).

If it’s equipment, I can then look up the value of a product and show a few product details on the ServiceAppointment record.

I was using early bound records but when I tried to get the serviceAppointment.Resources I got a casting error.

The odd thing was I could step through the code calling it from a console app but I was getting an error when the plugin was running.

The error was so odd I had to get someone to look at my code to check if I was doing a schoolboy error.

I knew it wasn’t a problem the Resources field was empty because I was checking it, it definitely had a value, the only problem was I got an error every time I tried to get it.


Finding the Error


To find the error, first I changed the code to throw an InvalidPluginException and this then puts out my tracing lines in the plugin.  Which is good because I recently blogged about mocking up tracing and have been using tracing whilst debugging some plugins

CRM 2011 – You can now add tracing to your plugins

CRM 2011/2013 – using ITracingServicing and Mocking it up

So using the tracing line I could work out where the problem was occuring and see the casting error – FACE to FACE with the beast

The question was what value was in the resources field?

Debugging with the Plugin Registration tool

I used the plugin registration tool to set profiling on my ServiceAppointment then this spits out a file with all the serialized field values.  You can then use this file to rerun the code in the Plugin Registration tool and attach the debugger to the plugin registration tool.

This is a lot better method than remote debugging because remote debugging stops the CRM server from running, so can hold up other developers/testers on that CRM instance

Here is a good article if you need to use the Plugin Registration tool for some debugging

I finally got to the ServiceAppointment.Resources, instead of a List of ActivityParty I found it had this

This was the line causing the casting error

 List<ActivityParty> resources = (List<ActivityParty >)serviceAppointment.Resources.ToList();

The error it was throwing was this


Now that I was stepping through the code, I could have a look at the Entity attribute and retrieve the Resources value using Late bound code and this worked fine.


var entities = ((EntityCollection)  entity[serviceAppointment.GetAttributeName(x => x.Resources)]).Entities; 
                ActivityParty resources = null; 

                if (entities. Any())
                    var firstOrDefault = entities. FirstOrDefault();
                    if (firstOrDefault! = null)
                        resources = firstOrDefault. ToEntity< ActivityParty>();}


So the error was linked to the early bound class and there is some problem with it.

I had already spent way to much time writing this simple plugin, so I just used the work around getting the value from the Entity class and used late bound methods to get the data.

I did think about correctly the entities file but this would have been overwritten when anybody refreshed the early bound entities.  So I decided to go with the code above and retrieve the resources using the early bound entity.


Plugin Registration tool

Using the plugin registration tool is an excellent way to debug plugins on a server but it can be done on your local machine, so it doesn’t impact the other developers working on the project.

All CRM Developers should know about the Plugin Registration tool, I mention this because some new CRM Developers have never used the Plugin Registration tool because they only deploy plugins using the CRM Developer toolkit.

So dust off the plugin registration tool and go a bit old school on your CRM.

CRM Developers don’t know what they don’t know!

There must be a happy medium somewhere between being totally informed and blissfully unaware.

Doug Larson


I read a fantastic article today on boingboing with the title

Why we are unaware that we lack the skill to tell how unskilled and unaware we are

It starts with a great quote

Each one of us has a relationship with our own ignorance, a dishonest, complicated relationship, and that dishonesty keeps us sane, happy, and willing to get out of bed in the morning. By David McRaney


The article mentions Nescience, so I thought I would use it but first lets understand what it means



Lack of knowledge or awareness; ignorance.

How is this relevant to CRM Developers

When you start out as a Developer and CRM developer you don’t know much and the main problem is

You don’t know what you don’t know


No I didn’t type that line twice or incorrectly, what I’m trying to say is junior CRM developers/ people starting CRM development have a lot to learn.

  • Knowledge of all CRM customization techniques
  • CRM Development Best Practices
  • Writing well structured code
  • Using the right Customization for the right job
  • CRM Infrastructure (e.g. Servers and components)
  • Testing and debugging
  • Converting customer requirements into solutions
  • Learning new CRM functionality
  • Lots and lots of other things

Getting it working

The first stage of improving is getting hands on experience with CRM development/customization.  At the initial stage this is where you know the least and don’t know enough to realise how much you have to learn.

The initial steps are getting practical examples to work e.g. Getting your hands dirty by creating entities, fields, views.

  • Creating new entities/fields/views/relationships and other GUI customizations
  • Creating workflows/business rules
  • Writing plugins/custom workflows
  • Integrating WCF webservices with CRM
  • Writing CRM Applications

This article about Knowing and Not Knowing is a great article which has a great visual and quote

The important realisation is understanding the areas which you have to learn and making a plan to learn about them

The key stage is moving from

Don’t know what you don’t know


Know that you don’t know


Doing it right

The CRM developer will at some point have got experience doing most of the different CRM customization types and will be comfortable with the process of creating them all.

The good CRM developers will start to move ahead of the average/bad CRM developers because they will start to produce good quality customizations and write plugins/custom workflows/WCF which are well structured/readable.  These customizations are easy to read/understand and easier to maintain and modify

Good CRM developers have a detailed knowledge of how CRM customizations work and the underlying CRM infrastructure.


How to learn what you don’t know

I started off this post by mentioning most people lack the skill to tell how unskilled and unaware they are

Sometimes this is because of ignorance and you simply don’t know what you don’t know.

There are actions you can take to learn about CRM Development


Read blogs

great examples of good CRM custmoizationswritten by great CRM Developers.  Good blog posts not only show you new functionality but also teach you the logic behind it and throw in a few best practices as well.

Example of new functionality you haven’t used yet.

Read Books

I recently wrote a blog about some great books for developers

Recommended Books for Developers

Books offer something different from blogs and articles.  They are focused and in depth look at a subject.


Correct Attitude

At some point the good CRM developer realizes he has a whole bunch of stuff he should learn about, but the list is big and the only way to tackle it is to constantly keep learning and improving on a daily basis.

Learning to be a better CRM Developer is like eating an elephant, one bite a time.

Don’t be afraid to question what you don’t understand, Ask fellow CRM developers at work or raise questions on forums.


CRM Customizations – Doing

Writing customizations will help you learn and improve.  Experience is a key for CRM developer, you will get to a level where you are comfortable with the process of creating CRM customizations.

Once you can easily create customizations the next stage is creating great customizations.  Customizations which will be easy to understand, maintain, extend and debug.


Learn from your colleagues – Peer Reviews

You can talk to fellow CRM developers about CRM development, the best way to do things, tips on creating customizations, mistakes to avoid.

Having your code peer reviewed is a great way to get feedback on your customizations


Learn from your mistakes

You will create bugs, you will choose customizations which don’t work because they are technically not correct.  You will have peer reviews where your code gets criticized.

Don’t take peer reviews personally, but learn from them, improve and don’t make the same mistakes in the future.  I personally find mistakes stick more vividly in the memory


Learn from previous coding – the good and the bad

You will have to work on projects written by other CRM developers.  Use this as an opportunity to find out the good customizations and the bad customizations.  Focus on why code is good and why the code is bad.

You take the good things and remove the bad things from your own customizations/coding.

Learn in public

A great way to learn is by writing blog posts, answering forum questions and learning with feedback and interaction from other CRM developers.

It’s even more fun learning with other people


known unknowns

I will finish with this classic quote from Donald Rumsfeld

There are known knowns. These are things we know that we know. There are known unknowns. That is to say, there are things that we know we don’t know. But there are also unknown unknowns. There are things we don’t know we don’t know.

Donald Rumsfeld