Hosk’s Top CRM Articles of the week – 21st September

Lets start with a quote

To forgive is to set a prisoner free and discover that the prisoner was you.

I have got two articles of the week this week (it’s a fluid system) and neither of them are really articles.

Article(s) of the week

CRM Developer Extensions v1.2.0.0

The alternative to CRM Developer toolkit created by Jasson Lattimer CRM Developer Extensions is improving rapidly.  If you wondering why this is important then read where is the CRM developer toolkit for CRM 2015 and CRM Developer toolkit alternatives.

CRM Developer extensions has added some great new functionality

  • 1 click deploy plug-ins and custom workflow assemblies from Visual Studio
  • 1 click deploy reports from Visual Studio without having to go through CRM
  • Added CRM TypeScript template
  • Web Resource deployer

Importantly this works with CRM 2015 and it’s free

Podcast of the week

CRM Podcast TypeScript and JavaScript with David Berry

When ever I read or hear Dave Berry talk about CRM or TypeScript I learn something new and this podcast is full of interesting views and opinions.  It’s quite a long podcast about an hour long

Below we have some more Dave information and Links

Dave Berry MVP Q&A

Dave also did a great Q&A, easily the funniest one

Dave has a great article on Typescript and CRM
Introduction to TypeScript for (Xrm) Developers

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

This article is the one I wrote, it’s more an introduction to typescript and where to find some more information

Best of the rest

Why the advanced find is a CRM Developers best friend

The Advanced is awesome, find out why

Why CRM Developers should always start with the CRM SDK

Always start with the CRM SDK, it will help you learn new features and functionality.

Undocumented Useful Script Functions in Dynamics CRM

Microsoft has a bunch of inbuilt script functions used by Microsoft Javascript code.  You can use those functions in your own code, you do need to be aware this is unsupported and Microsoft could change the Javascript at any moment

Just because everyone is talking about CRM 2016 don’t forget CRM 2015 Patch

There is a new CRM 2015 patch

Understanding levels of abstraction can improve your code design

Improve you code design and consider the levels of abstraction in your code

How to free storage space in Microsoft Dynamics CRM

Some great tips on reducing storage space on CRM online instances

Are your CRM plugins creating technical debt?

Is the way you write plugins causing technical debt in your CRM solutions?

5 Ways To Improve Microsoft Dynamics CRM Performance

Some tips to improve performance

Should you hire a Rockstar developer for your CRM project?

Do you want to put all your CRM development eggs in one basket?

Why you shouldn’t put unsupported customizations in Microsoft Dynamics CRM

Some reasons why you shouldn’t write unsupported customizations

Great Tool – OrgDBOrgSettings tool for Microsoft Dynamics CRM

Useful tool to tweak the CRM DB settings

CRM 2015 – How to Diagnose plugin errors

How to diagnose plugins errors, tips and good practices.

White Paper – Microsoft Dynamics CRM 2015 Performance and Scalability Documentation

Fantastic white paper on performance and scalability.

CRM and SQL Tip #01 – How to find out the Security Roles assigned to the user

SQL query to find security roles assigned to a user

13 signs your project is doomed

Signs you CRM project could be about to hit trouble.

Programming

Why Other Tech Talent Gets Paid More Than You by Lane Campbell 

The Myth of the Rockstar Programmer

good developers vs bad developers

Other

A Dozen Things I’ve Learned from Charlie Munger about Inversion (including the Importance of being Consistently Not Stupid)

4 easy ways to communicate more clearly in writing

I have 75k saved up in my bank account. I’m 24 years old. I want to generate passive income and retire by 30. What should I do with the money or how should I invest it?

Book Lovers Alert: 8 Of The Most Spectacular Libraries In The World

How netflix reinvented HR

Netflix slideshow on HR

Good introductory article on machine learning

28 ideas to become 5 times more productive

Elon Musk’s First Wife On What It Takes To Become A Billionaire.

Disney’s $4 Billion Steal

Previous top picks

Hosk’s Top CRM Articles of the week – 1st September

Useful Hosk Links

Hosk list Of CRM 2013 Tools

A list and review of CRM 2013 tools, this will probably work in CRM 2015 as well

Hosk’s CRM Developer Articles

A collection of my favourite CRM Developer articles I have written

MB2-703 – CRM 2013 Customization and Configuration Certification Information

All the CRM 2013 content to help you pass the exam

HoskWisdom – Hosk Developer Quotes

 Words of Wisdom from the Hosk.  I have written over 900 articles, surely I should have said a few memorable things

Advertisement

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

http://blog.sonomapartners.com/2013/03/debugging-crm-2011-plugins-with-the-plugin-profiler.html

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

System.Linq.Enumerable.CastIterator<Ntt.Dynamics.Crm.HondaPLCC.Entities.ActivityParty>

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

Unaware

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

nescience

1.

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

or

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

To

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