Hosk’s Top CRM Articles of the week – 28th September

I have been de-cluttering my stuff the last week, unsurprisingly I have too much stuff, which makes it difficult to tidy it all the way.

This book is amazing, it has changed me from a messy person to a tidy person who now folds his pants and socks! because as the author says “folding is fun”

The Life-Changing Magic of Tidying: A simple, effective way to banish clutter forever

The two key points which have changed the way I view tidying.  You are not deciding what to throw out but what to keep.  If an object doesn’t give you joy then get rid of it.

“Keep only those things that speak to your heart. Then take the plunge and discard all the rest. By doing this, you can reset your life and embark on a new lifestyle.”
― Marie Kondo, The Life-Changing Magic of Tidying Up: The Japanese Art of Decluttering and Organizing

 

The other key concept is once you have decluttered, everything has it’s place.  All of your items should have a distinct place and you put an item back in it’s designated place.

Buy the book, it’s awesome and if you click the link from this page I will get 5 pence or some huge amount :-).  I will be buying some for Christmas presents

Quote of the week

Knowledge alone is static. Know-how is knowledge in motion – Gold rule of software engineering

Joshua Levy

Article the week

Understanding the Microsoft Dynamics CRM Performance Center

Microsoft have added an awesome tool to show you the performance of your CRM forms but then it seems to get hardly mentioned.

The Cobalt blog is the best explanation of how it works I have read.

The most important bit which I keep forgetting, how to get the form up

Hit Control+Shift+Q to open the Performance Center window

Dynamics CRM performance troubleshooting

Good blog with lots of tips on finding performance issues

 Best of the Rest

CRM Web API Preview – Generate Strongly Typed Objects from Metadata Document

Great blog post on using the new Web API preview to create strongly typed objects and I personally loved strongly typed objects

What happens when you publish a duplication rule

have you ever wondered, me neither but someone has.

Online proctored Microsoft certification exams are now available

You can do your CRM exams in your pants in the comfort of your own home, beware they will use your laptop webcam to check your are not cheating.

CRM 2015 – Advanced find to return all enabled users with a security role

A Hosk blog talking about advanced finds

A list of CRM blogs you should be following

A small list of great CRM blogs you should be following

What’s new in CRM 2016 and why you should read the preview guide

Hosk’s looks at the CRM 2016 preview

Getting Cortana to Work on Australian Windows Phones

It’s good to see people putting Cortana to work

Microsoft Dynamics CRM 2013 White Papers & Technical Documentation

A great list of all the CRM 2013 white papers

CRM 2011 – How to set up a lookup using Javascript

How to set a lookup using JavaScript

Storing the “Last Activity” on a Microsoft Dynamics CRM record

Good blog to show you how to store the last activity, who needs machine learning

CRM 2011 shortcuts

CRM has lots of shortcuts, who knew

CRM Plugins – Stopping infinite loops and understanding PluginExecutionContext.Depth

How to stop infinite loops in your plugins, it’s all about the depth

How to get the server time in Dynamics CRM?

You never know when you need to get the server time, it’s like hammer time but better

Great list of CRM version numbers, Release Dates, Build Numbers, and Collateral 

It’s hard to remember build numbers, so luckily someone has collated them all in one list for you

how to Manage Microsoft Dynamics CRM Online updates

A great article from Microsoft about managing updates, you can turn them off to have one a year.

CRM 2015 – Why filtered views are useful

Filtered views are more awesome than you know

New Forms Authentication in ADFS 3.0 and IFD for Dynamics CRM

ADFS 3!

Lookup Field vs Option Sets in Dynamics CRM

Which is better, when should you use a lookup field?

MobileCRM: A different mindset in projects

great article on how to approach mobile CRM projects

Entity Image updater tool

It’s a tool to update entity image

Programming

he Golden Rule of Software Engineering

code reviews

other

Sleep May Be One of Our Most Powerful ‘Antibiotics’

Tires, coffee and people

Tim Ferris Morning Rituals podcast

How Do Excellent Performers Differ from the Average?

a dozen things I’ve learned from charlie munger about mistakes

tips on Writing Funny by Scott Adams

Keeping Things Simple and Tuning out Folly

Solitude and Leadership

What Two Teenagers Learned From Watching Every Best Picture Oscar Winner

Previous top picks

Hosk’s Top CRM Articles of the week – 21st 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

CRM 2015 – How to diagnose plugin errors

failure-to-diagnose

This blog talks about a plugin error which I have seen a number of times when using the Plugin Developer Toolkit, it will discuss how to diagnose plugin errors in general.

Before I talk about plugins can I encourage people to vote on the connect item to get the CRM Developer toolkit working with Visual studio 2013, if you can’t wait for Microsoft to fix it then read my blog post CRM Developer Toolkit Alternatives

Hosk CRM Brain

I like to think of my blog as my CRM brain uploaded to the internet, so whilst reading this you are currently crawling through my CRM brain.  This allows me to search my CRM brain when my real brain forgets how I resolved a problem, actually sometimes I even forget I have experienced a problem and get pleasantly suprised when I have found not only did I have the problem before but I blogged the solution.

The benefit of me blogging about CRM is I benefit and other people who read and search my blog.

My goal in writing articles focused on errors is not only to write about how to resolve the issue but additionally look into the cause of the problem and , the WHY.

Knowledge helps when things go wrong

There is always a difference between theoretical knowledge and practical knowledge.   You can learn the theory of something but find it’s different when you try to use the theory in practical use (e.g. after reading about plugins you then try to write a plugin) you there are gaps in knowledge which you quickly find.

When developers start to plugins they usually go through

  • learn to write plugin code, find lots of errors
  • try to deploy plugin, error haven’t signed the plugin, error permissions etc.
  • Slowly but surely the developers experience fewer problems or problems they know how to resolve

Indepth knowledge of how Microsoft Dynamics CRM works and the underlying plugin infrastructure becomes extremely important when things go wrong.  When errors appear and hold up development, developers need to understand the cause of the error but why it’s complaining, the answer is usually understandable if you understand

  • how the CRM developer toolkit works
  • The various parts of the CRM Developer toolkit
  • The CRM plugin execution framework
  • The roles and privileges needed to deploy plugins

Some useful Hosk Plugin blog posts

The CRM developer toolkit is great (which is why I get annoyed it hasn’t been updated because it automates a lot of the repetitive actions needed to deploy a plugin using the plugin registration tool.) but I feel CRM Developers should learn how to use and deploy plugins using the plugin registration tool.

I use the plugin registration tool to inspect what plugins and steps are deployed and the ability to change the view to see what plugins are deployed for each entity is really useful when investigating bugs on CRM solutions you are not familiar with.

Most of the time you don’t want to mix using the plugin registration tool and the CRM developer toolkit because the CRM developer toolkit will overwrite the changes you make manually next a developer uses it to deploy CRM customizations.

The plugin registration tool is great for viewing the plugins deployed and its portability allows you to use it in customer environments.

If the CRM Developer toolkit gets in a mess you might need to use the plugin registration tool to quickly update or deploy a plugin whilst you fix the plugin developer toolkit.

I had an error previously but the problem was the CRM developer toolkit had got out of sync and I struggled to resolve this problem.  You can read about my frustrations with the CRM Developer toolkit

Dealing with Plugin errors

If When you experience a plugin error I would recommend you first read my blog on common problems because I cover the most common errors.

If you don’t find the answer then stop and think about the potential cause of the problem.  Many developers can go into a mild panic mode when they encounter an error, instead of logically thinking about the problem they instantly go and get a senior developer to help them.

Then when the senior developer is at their desk, they explain the problem.  The process of explaining the problem to the developer, the solution to the problem can become clear.  This is known as rubber ducking or I call this Cardboard developer

When you encounter a plugin problem or CRM developer problems, follow these steps

  1. Stop
  2. Engage Brain\Think
  3. What’s happening?
  4. What should happen?
  5. Make a list of the possible causes of the problem
  6. Investigate your list

If you can’t resolve the problem, you can then at tell the developer what you know, what you have tried.

I don’t encourage any developers to suffer in silence but it’s more beneficial for you own personal learning if you try to understand and resolve problems yourself.  The major benefit of trying to resolve the problem yourself is you get in the habit and become less dependent on the help of your colleagues.

Don’t Assume, know

Don’t Assume, Know is a Hosk mantra I tell myself when investigating problems or debugging.  I have wasted many hours investigating problems and looking for solutions based on an incorrect assumption.  When dealing with problems don’t assume anything, check assumptions and cross them off.  Lots of times you will find the problem.

Plugin Error Messages

The error messages Microsoft Dynamics CRM throws are a mixture of a confusing statement with a nugget of truth tucked inside.  To developers new to CRM development they are just unhelpful messages.

As your experience and knowledge of CRM development increases you will find they often point you in the right direction but you need to have built up a map of the CRM landscape, so you know where to go and check.

Plugin Error Example

This is common error I have experienced a few times but I was trying to deploy a plugin using the CRM developer toolkit and I got this error

Error registering plugins and/or workflows. Plug-in assembly does not contain the required types or assembly content cannot be updated.

Lets break down the message to try and decify the problem

  1. It can’t register the plugin/workflow
  2. Plugin Assembly does not contain required types or the assembly cannot be updated.
  3. So we know the plugin assembly (the DLL) exists but it cannot update it.

The first thing to do is know not assume.  So I opened the Plugin Registration tool and found the DLL.  I could see it had three steps.

I then looked at the RegisterFile.crmregister file and found this had two steps.

The problem was because we were trying to update an assembly with 2 steps but the assembly had 3 steps.  It couldn’t update the assembly because it was too different and this error message was letting us know (in a slightly confusing way).

I have experienced this problem before and the solution to the problem is to unregister the Assembly and install it again.

This problem has occurred when I have created new plugins and sometimes when I have updated a plugin maybe in a different solution but for some reason I couldn’t update the DLL.

In this case how the extra step got into the assembly was a complete mystery but it’s OK to delete the plugin assembly because I knew I was going to deploy it again and install a new version of the Plugin assembly.

Hosk’s Top CRM Articles of the week – 19th August

Article of the week

Dynamics CRM 2015 JavaScript Form Notifications on Steroids

Great article on how to beef up the notification in CRM by using the solution provided for free on codeplex.  Those boys at Magnetism are a great bunch

call workflow in CRM 2015 easily from Javascript

I really liked this article as well

Best Of the Rest

CRM 2015 – How to decompile a plugin Assembly (DLL)

Hosk blog post talking about how to decompile a plugin assembly and more importantly when and why you might need to do this.

Gamifying Sales Comp

It’s all about the games you can play to motivate your CRM users at the moment, even I wrote a blog post a couple of weeks ago Is Gamification in a Microsoft Dynamics CRM a gimic?

Replicate Right Click behavior of Dynamics CRM Grid on Custom Grids

Interesting article about adding right click behaviour

Why understanding abstractions can help you write better code

read the article and find out why?

Adding JavaScript to Quick Create Forms in CRM 2015

how to isolate the quick create form in and write JavaScript just for it.

looking at CRM performance issues

Always good to know about performance issues before your CRM suffers from them.

Sample code to check if User is a member of a team C# CRM 2011/2013/2015

Simple but useful

Building not in queries in advanced find

A classic requirement

Angular with TypeScript

Pluralsight have a training course on Angular with TypeScript which is a dream for Dave Berry

Tips & Tricks for debugging unfamiliar AngularJS code

indepth article looking at debugging AngularJS, I haven’t seen any CRM projects use AngularJS yet but it might only be a matter of time.

Workflow ExecutionTimeSpan

good article because it shows some creative thinking, whilst teaching you about the underlying data in CRM.

Multi select field for Dynamics CRM 2013/2015

I haven’t needed a multi select for quite a while but I remember when it use to crop up all the time.

A free customizable Editable Grid for Dynamics CRM 2013/2015!

Does what it says

programming

Is Egoless Programming still relevant?

When Does DRY Become ARID?

Excellent article on the factory pattern using warriors and wizards.

how to become a better coder overnight

How Good Developers Deal With Bad Code

15 Ways To Write Beautiful Code [That Have Nothing To Do With Testing]

Other

Mental Model: Misconceptions of Chance

Lenovo preloaded laptops with reformat-resistant perpetual crapware

How To Be Loved By Everyone: 6 Powerful Secrets

The Science of Obesity

4 Tips to Boost Your Creative Thinking Skills

Schopenhauer: On Reading and Books

Previous top picks

Hosk’s Top CRM Articles of the week – 10th August

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

Hosk’s Top CRM Articles of the week – 10th August

Article of the week

CRM 2015 Custom Alerts and Popup Dialogs in JavaScript

Great article on creating custom popups in Microsoft Dynamics CRM.  It’s unsupported but this is a common requirement and this solution is very neat and tidy.

CRM

Using CRM from an external website – part 2: research

Good article looking at CRM integration with external websites

Testing CRM rollups and .NET versions

Hosk had problems testing CRM and it was all down to the .NET version

My CRM project failed because of lack of user adoption. Really?

Some good advice on CRM projects, make sure there is a reason

Is Gamification in a Microsoft Dynamics CRM a gimic?

A look at gamification in CRM.  Hosk blog

Hardcore CRM: Do a major upgrade of a plugin version!

I haven’t used versioning in plugins very often, although I have often wished we had.  I didn’t realise you could end up with different versions of the same plugin deployed

Thoughts on CRM Design and converting user requirements to CRM solutions

Hosk blog on CRM design and solutions

New XrmToolBox plugin : Chart Manager

A great new tool in the XrmToolBox

CRM 2015 – plugin deployment options

There are lots of options when you deploy a plugin, learn what they are

Tip #449: CRM Online Trial Setup – Update

When setting up your CRM trial make sure you click the “IT FOR DEV” button and hopefully Microsoft won’t ring you up trying to sell to you

Using “People” as a currency in CRM

It sounds dodgy but it’s creating a new currency in CRM called people, NOT buying and selling people

useful analysis of Parature and CRM integration

A look at the current parature and CRM integration.

Build and Deployment for Microsoft Dynamics CRM

building and deploying CRM

programming

Self forming teams at scale

Doing Terrible Things To Your Code

Other

Why smart meters matter

Tesco To Remove Ribena, Capri-Sun & Other Sugary Drinks From It’s Shelves

Seven Leftovers You Should NEVER Reheat (As This Could Poison Your Family)

Two Forms of Human Motivation: Gain And Prevent Pain

How Walking in Nature Changes the Brain

The Checklist Manifesto: How to Get Things Right

A Dozen Things Charlie Munger has said about Reading

great article on evolution from the BBC

5 Books That Will Change Your Life

Intel and Micron Produce Breakthrough Memory Technology

Previous top picks

Hosk’s Top CRM Articles of the week – 24th July

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

Testing CRM rollups and .NET versions

In this article I will talk about testing patches and how .NET versions can cause odd errors.

Rollups and CRM Version

I had a customer who was using CRM 2013 Service patch 1 and wanted to test their customizations still worked when CRM 2013 SP1 rollup 3 was applied.

Testing a new CRM service pack or rollup involves using a new server and CRM instance.

You can have many CRM organisations deployed on one CRM server but if you upgrade the CRM server it will effect all the CRM organisations and I don’t know any method to roll back rollups.

Why can’t you rollback CRM versions

To understand the question you need to think what happens (could happen) when you apply a rollup

  • Possible changes to the database tables
  • Update to CRM SDK
  • Depreciating certain functional in CRM SDK

Database changes

Microsoft might change the whole structure of the CRM database between service patches and rollups, which is one of the reasons Microsoft recommends you do not write any code/customizations/reports which run directly against the CRM database.  Microsoft provide filtered views and the CRM SDK for you to integrate the CRM database.

I think during the CRM 2013 update Microsoft used to have base and extension tables for each entity. e.g.

  • entitynameBase
  • entitynameExtensionBase

e.g.

  • accountBase
  • AccountExtensionBase

Here is some more information on the merging of tables, which explains how you can run the table merging as a separate job but you have to do it.

Run the base and extension table merge as a separate operation

I have written before about unsupported customizations before – Why you shouldn’t put unsupported customizations in Microsoft Dynamics CRM.  The primary reason you should avoid unsupported customizations is if you have to escalate an issue to Microsoft they offer limited support if you have unsupported customizations (because those customizations might be the cause of the behaviour/bug)

New functionality in CRM SDK and CRM

Usually (but not always)

  • Roll ups contains fixes
  • Service packs contain fixes and new functionality

New functionality doesn’t usually break anything but sometimes existing functionality might change.

The key point is the CRM SDK will have changed,

Old CRM SDK functionality depreciated

With one hand Microsoft giveth new functionality and the other hand they take functionality away (depreciate).

You should always read the What’s new for a new release of CRM – Why you should read the What’s new for developers because it lists not only the new functionality but includes what’s being depreciated in Javascript and CRM SDK.

Applied patches but stuff not working

I applied the rollup to CRM 2013 SP 1 rollup 3 but when I tried to test CRM, I noticed I was getting unusual errors.  The core functionality of CRM was working but I was getting errors when the plugins triggered calls to WCF web services.  Below is the error

The Web Service plug-in failed in OrganizationId: 3666c2e6-04f4-e411-80c9-000c292122be; SdkMessageProcessingStepId: 2ccabb1b-ea3e-db11-86a7-000a3a5473e8; EntityName: incident; Stage: 30; MessageName: Create; AssemblyName:
Inner Exception: System.TypeLoadException: Could not load type ‘System.Runtime.CompilerServices.ExtensionAttribute’ from assembly ‘mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′.
at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)

To find this error I had to turn on tracing and look into the event logs because CRM was not giving much information.

I have highlighted the key part of the error.

This article was useful

Could not load type ‘System.Runtime.CompilerServices.ExtensionAttribute’ from assembly ‘mscorlib

This seemed a classic DLL type error, this usually occur when you there are differences between .NET versions or DLL’s deployed.

In this particular scenario I could compare the .NET version installed on the working CRM environment and the .NET version and other DLL’s in the new upgraded environment.

So I needed to check the .NET version, Microsoft has a great page on this

How to: Determine Which .NET Framework Versions Are Installed

Be careful because you have to read it carefully.  I was checking the .NET versions in regedit (full instructions in the link above) and the folder said v4.  I was expecting a 4.5 folder, so I assumed it was version 4.

Its a better to know facts rather than making assumptions particularly when trying to find a problem.  In the example above I assumed the .NET versions where the same, which meant I then wasted time investigating other parts of the server and DLL’s looking for potential problems.

If I had read the article more carefully  it more carefully I would have noticed this very important section

The value of the Release DWORD indicates which version of the .NET Framework is installed.

 

The folder will be v4 but if this has been updated it will have a new Release registry value and the number in this registry settings tells you what version of .NET is installed

.NET versions

 

I found there was a DWORD value in the working CRM Server which indicates I had 4.5.1 installed

378675 .NET Framework 4.5.1 installed with Windows 8.1 or Windows Server 2012 R2

I checked on the server I was updating CRM 2013 SP 1 to rollup 3 and it only had .NET framework 4

What was happening was the web services were compiled with .NET 4.5 but when they tried to run on the new server it couldn’t find the correct dll versions, this caused the odd errors.

What I learnt

Don’t make assumptions – Know don’t assume.

If web services are not working check the .NET versions and look for the secret DWORD registry setting Release.

 

Hosk’s Top CRM Articles of the week – 24th July

Article of the Week

Asynchronous Batch Process Solution Revisited – part 1

Asynchronous Batch Process Pattern: Part 3

I enjoyed reading these two articles

Best of the Rest

CRM 2015 – Understanding impersonation in plugins and knowing when to use it

A look at plugins and understanding impersonation, when, why and how to use impersonation

Updating and Publishing webresources directly from Visual Studio

A tool to update web resources from Visual studio

MICROSOFT ANNOUNCED ITS CERTIFICATION FOR DYNAMICS CRM ON-PREM RUNNING AZURE IAAS

It’s finally certified

CRM 2013 – Workflow error AccessCheckEx

The Hosk got an error, find out how I worked out the cause and my solution

Querying More than 5000 records in Dynamics CRM

Interesting article talking about paging when selecting lots of records

CRM 2015 – What is the CRM Outlook reading Pane?

The CRM outlook reading pane caused me problems this week

Visual Studio 2015 Shared Projects and CRM Plugins Development

Excellent new functionality in Visual Studio 2015, help you get round the dll/ilmerge problems

CRM 2015 – Understanding CRM Metadata

What is Metadata in CRM 2015

Tracking the Movements of a Case

Leon Tribes shows how a no code solution to tracking the history of a case.

Microsoft Dynamics CRM Mobile SDK Update and Azure Mobile Connector SDK

CRM SDK for Mobile and Azure

CRM 2013 – Understanding SystemJobs and Async Plugins

Understanding System jobs and async plugins

Using Windows Resource Monitor to Find Unusual Performance Bottleneck

Great use of windows resource monitor to diagnose a problem

How to cascade activate / deactivate (SetState) in CRM

Do you know your cascading

Getting the CRM Developer toolkit working with Visual Studio 2013

Tutorial to get CRM Developer toolkit working with visual studio

programming

Announcing the latest improvements for the F12 developer tools in Windows 10

Group Flow in Software Development

7 Tools to help you gather better software requirements

Building your mental toolbox for solving coding problems

Other articles interesting the Hosk

free minding hacking book

awesome mind maps/sketches of books

Why Exercise Won’t Make You Thin

Billy Beane on Making Better Decisions and Avoiding Biases

Mental Model: Regression to the Mean

BBC iPlayer ‘watched by more than 60 million people outside the UK for free’

“How To Pick The Perfect Book Title”

short master course on Thinking about thinking

Previous top picks

Hosk’s Top CRM Articles of the week – 17th July

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

Hosk’s Top CRM Articles of the week – 26th June

Article of the week

CRMDeveloperExtensions from Jason Lattimer

I just want to let people know, Jason Lattimer has uploaded his CRM Developer extensions to Github, so download it and have a play.

Top Ten Secrets to a Successful CRM Deployment: Part One–People

Great article from Leon Tribe on the secrets to a successful CRM deployment.  There are lots of pieces, lots of people, lots of customizations, lots of data.  You need to herd them all in the direction of success

Best of the rest

CRM 2015 – CRM developers should think in Entities

Hosk blog post on why CRM developers should view everything as entities.

Pass Plugin Context Message C# Exception to Form Script (Javascript) during CRM Ribbon Calling Action

How to catch plugin errors in your javascript

Compare This Year to Last Year with a Dynamics CRM chart

The CRM Chart master gives another chart master class

#IoT2CRM: The gateway revised

I enjoyed reading this article, an interesting piece of using Gateways and thinking about the data you use in CRM projects

CRM 2013 – How to stop these annoying things in Microsoft Dynamics CRM

There are a few annoying things which feels good to squash and stop.  Liking pending emails, annoying welcome woman, incorrect format, send report pop up etc.

Rolling in a New Feature to Stay Updated in Dynamics CRM

I like the quirky way you can use rollup fields and it’s daily rolling up functionality.  It would be good if CRM had schedule functionality

Hide / Show Export to Excel button for specific Entity / Specific View

How to hide the export to excel button for individual entities

CRM 2015 – how to find Statecode value

A quick way to find a statecode value

How to Add Parameters to a Fetch Based Report

A good blog showing you how to add parameters to fetch based reports.

The Workflow Executor for CRM2011, CRM2013 and CRM2015

CRM systems can have lots of workflows in various stages.  This free tools lets you set the status for many workflows at once.

Tip #418: 3 ways to find the blocking attribute

3 ways to find an attribute

Did you know

Explanation of some of the default fields

programming

Joel Spolsky : The law of leaky abstractions

Three great articles on debugging

https://medium.com/@codingpains/the-most-powerful-debugging-tools-in-the-world-part-1-9e4e20a622dc

https://medium.com/@codingpains/the-most-powerful-debugging-tools-in-the-world-part-2-967dc01e9960

https://medium.com/@codingpains/the-most-powerful-debugging-tools-in-the-world-part-3-d596176ded82

The Startling Cost of Losing a Developer

Think twice before logging

34 CSS Puns That’ll Make You Laugh, Even If You Aren’t A Web Designer

Continuous Delivery Among the Donkeys

How peer review leads to quality code

other

Shhh, Google Chrome is listening

8 Things Every Person Should Do Before 8 A.M.

Windows 10 inside story

Probability Trumps Predictions When Making Forecasts

How It’s Made Series: Beats By Dre

Exclusive: Satya Nadella reveals Microsoft’s new mission statement, sees ‘tough choices’ ahead

Hearthstone: how a game developer turned 30m people into card geeks

Previous top picks

Hosk’s Top CRM Articles of the week – 19th June

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

CRM 2015 – CRM developers should think in Entities

The humble Entity is one of core building blocks of CRM and CRM development.

  • CRM developers need to view the world as entities
  • You need to translate users work items to entities
  • Understand out of the box entities and custom entities

When CRM developers look at things they should see things in entities like the matrix picture.

When a customer tells you the requirements you should be thinking about it in entities

You are an entity called CRM Developer!

What is an Entity

Entities do a lot in CRM, to understand what they are and what they do I think it helps to view them in different ways

Customer

Entities are used to model the business data of the customer to accompany the out of the box entities which exist in the default CRM system (account, task, contact, business unit)

CRM Database point of view

  • Every entity in CRM is a table in the CRM database.
  • Every field on an entity is a column on the entity table.

CRM Dev point of view

Most entities have at least one form in CRM.

Customizations are organised (to some extent around entities) in your solutions

Task

CRM Developer Plugins

Plugins are triggered by actions on Entities (you can add multiple triggers on a plugin).  The messages (read actions on an entity) aer

  • Create
  • Update
  • Delete
  • Retrieve
  • Retrieve Multiple
  • Assign
  • Share
  • Associate
  • Dissociate
  • Set State

Entity Status

Entities have a status and status reason.  These values can be used to drive the entity through a process/life cycle.  To learn more about Status and Status reason read the blogs below

CRM 2013 – Understanding Status and Status Reason – think before deleting them

CRM 2015 – how to find Statecode value

Security

Security roles set access rights on entities – Create, Read, Write, Delete, Append, Append To, Assign, Share.

Entities can be owned by users/teams and these provide access levels such as none, user, business unit, child business unit, organisational.

security

Start with the CRM SDK

When learning about topics in CRM it’s good policy to start with the CRM SDK and find the truth about entities, find out what properties and methods entities have.  When I use the term CRM SDK I mean the CRM SDK documentation

Development for Microsoft Dynamics CRM Online and on-premises (CRM SDK)

You could also look at the CRM Developer Website, which I wrote a blog about recently

CRM Developer Centre gets updated and it looks good

Entity

Microsoft.Xrm.Sdk.Entity

What properties/members do you get with the Entity

Entity Properties

The Entity has a number of properties but here are the keys ones

Attributes

The attributes parameter holds a collection of all the fields in an Entity.  The atrributes collection works by holding fields which have a value.  If a field is null it isn’t included in the attributes collection (when you call from plugins).

You often need to check for a value in the Attributes collection using the contains method

entity.Attributes.Contains(“name”);

This will create lots of if statements with contains, if true retrieve the attribute type code.  You can work around this by using Entity.GetAttributeValue which will get the value if the field exists in the Attributes collection or return the default value for simple variables or null for complex variables.  Read more about it using the link below

CRM 2013 – using Entity.GetAttributeValue instead of Entity.Contains

LogicalName
Each Entity has it’s own individual name stored as a string.  The logical name is useful because sometimes in the code you will need to know what type of entity it is e.g.

task, account, phonecall, contact.

The LogicalName can be useful if you have plugin code which is triggered on a number of different entities.

Id

The all important Id of the entity record.  This holds the Guid.  This is important because when you retrieve any information you can use this ID to retrieve the individual Entity record and ask for particular fields of interest.

EntityState

Gets the state of the entity, useful

Entity Abstraction and Early binding

Good practise for CRM developers is to use Early binding which will create an Entities file and allow you to create Account, Contact, Task records.

Early binding strongly types the field values for an entity.  These values are the same fields you would find in the attributes collection on the Entity object.

  • What are the benefits of early binding
  • Readability
  • moving type errors into compile time and not run time (e.g. compile time = developers, runtime = testing or users)
  • reduce syntax errors

The easy way to make your Entities file is to use the CRM Early bound generator

CRM 2013 Tool – CRM Early Bound Generator

Whilst you are there don’t forget to make your optionset enums

CRM 2013 – Create Enumerations for option sets

What has the Entity got to do with Abstraction?

When you are using early bound classes in your CRM code you are then extending Entity object with the new early bound classes

Entity –> Account, Contact, Task, etc

Using Entity can be useful when creating common functions because all your early bound classes inherit from Entity.

The code below checks the entity (which is an Entity object) to check the name.  The code in the example could be either a Task or PhoneCall.  The Complete activity either sets a task to completed or a phonecall to made.


            if (entity.LogicalName.Equals(Task.EntityLogicalName))
            {
                CompleteActivity(activity.ToEntity<Task>());
            }
            else if (entity.LogicalName.Equals(PhoneCall.EntityLogicalName))
            {
                CompleteActivity(activity.ToEntity<PhoneCall>());
            }

It’s useful to remember all early bound entities inherit from Entity.

EntityReference – Entity’s little brother

The EntityReference object in CRM is a lookup to an Entity object.  An EntityReference has LogicalName and Id (guid) of the entity.

When ever you see a lookup in a CRM form you know this is an EntityReference with just enough detail for you to retrieve the Entity object.

There is a good code tip is you can get an Entity Reference from an Entity object

Hosk CRM Dev Tip – Get EntityReference from Entity

EntityReference entRef = entity.ToEntityReference();

When creating new lookups on your forms, it’s best practise to put ID on the end of the field name, so CRM developers can easily find the lookups

Hosk CRM Dev Tip – add ID suffix to lookup fields

 

Hosk’s Top CRM Articles of the week – 12th June

Article of the Week

The article of the week is my article is the excellent and I want as many people as possible to go and have a look at his first steps in towards creating a developer toolkit replacement.

Possible developer toolkit replacement

I will add my blogs on the subject below

Where is the CRM Developer toolkit for CRM 2015?

CRM Developer Toolkit Alternatives

I will add the Connect suggestion here has 66 votes which is great because a week ago it had 9.

Best of the Rest

XRM code snippets

Some useful Javascript code snippets

CRM 2013 – Disabling a subgrid

Hosk article on how to disable a subgrid without actually disabling it.

Web API preview documentation released

The new Web API stuff, in an odd trial but unsupported offering!!!?!?

New XrmToolBox Plugin: Export to Excel

Don’t be limited by excel when exporting records with the

Getting the CRM Developer toolkit working with Visual Studio 2013

Steps on how to get the current CRM developer toolkit working with visual studio 2013

Upgrade vs Rebuild, Interest vs Responsibility

Good article from CRM MVP Leon Tribe on considering what to do with your customizations when upgrading

Turbo Forms: Get your JavaScript ready for CRM2015 Update 1

Scott Durow gives the lowdown on getting your scripts into shape to be able to use them with the new CRM 2015 SP1 turbo forms.

Create Button in CRM 2013/2015 Form without a Field using Javascript

A button without a field, what is this magic

Dynamics CRM – Security Role Automatically Assigned to imported Teams

Cheeky salesperson role automatically assigned on importing teams.  Probably some kind of reason for this but very annoying if you are not aware of this behaviour

Improve CRM query performance using compatibility version 120 with SQL 2014

Dramatic performance improvement when switching to SQL 2014

Scalability considerations for CRM / SharePoint integration

good article and worth a read

C# Development Tips for Microsoft Dynamics CRM

Great article on implementing C# dev to CRM

Kinect and CRM!!

It’s madness I tell you but it looks cool

PROGRAMMING

“How is Software Like a Skyscraper?”

Martin Fowler – Is Design Dead

great article on YAGNI by Martin Fowler

very interesting article on the history of lean development, I don’t know much about lean development but it sounds like agile without the rubbish bits

http://www.leanessays.com/2015/06/lean-software-development-history.html

Empires fall: Decentralize your code to avoid total collapse

The 8 Best Programming Books to Read Right Now if You Want to Distinguish Yourself

Software engineers are lazy bastards

31 Of The Best Kept Secrets Of Great Programmers

Microsoft: People Have Smaller Attention Span Than A Goldfish

Improving Your Craft with Static Analysis

What’s Fixie and Why Should C# Programmers Care?

TypeScript Futures

OO principles from Head First Design Pattern

The dangers of spaghetti code

OTHER

DESIGN THINKING… WHAT IS THAT?

Do something syndrome

The Disease of Being Busy

Neil Gaimen and Kazuo Ishiguro

Deep Habits: Spend Six Months to Master Skills

Strategy More: Inc. Success Bill Gates Warren Buffett
How Bill Gates, Warren Buffett, and 8 other successful people spent their summer vacations when they were younger

Previous top picks

https://crmbusiness.wordpress.com/2015/06/02/hosks-top-crm-articles-of-the-week-2nd-june/

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

CRM 2013 – Disabling a subgrid

This blog post will look at possible ways to disable subgrids in CRM 2013.  I had a requirement if a user made a case restricted then the case couldn’t be linked to any other cases.

Requirements

  • On the case form we had functionality to select a parent case and a subgrid to add child cases.
  • Case had a restricted bool field
  • Restricted cases could not link to any other cases

If the user set restricted to Yes I had to disable the subgrid and the case lookup, e.g. stop the restricted case from being linked

Disabling the case lookup field was was straightforward

  
Xrm.Page.getControl(fieldName).setDisabled(true);
	

Frustratingly for me subgrid control does not have a setDisabled method, this means disabling the subgrid would not be as straightforward.

Disabling a sub grid

This is a different story, a story with twists, frustration

An unsupported way

http://www.magnetismsolutions.com/blog/paulnieuwelaar/2012/02/28/Disable_Subgrids_with_Javascript_in_Dynamics_CRM_2011.aspx

  
// Disable a subgrid on a form
function disableSubgrid(subgridName) {
document.getElementById(subgridName + "_span").disabled = "true";
}
	

I’m not going to consider putting in unsupported changes because if you do then Microsoft will unsupport your customizations.  This probably doesn’t sound like much of a threat but if you find a bug with out of the box functionality Microsoft won’t even look at your customizations due to the unsupported code.  When the customer then finds out they have no Microsoft support because of your code.

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

From the Hosk Wisdom page 🙂

Don’t even think about making unsupported changes in CRM because Microsoft will un-support your CRM if they find out – Hosk

Don’t do unsupported CRM customizations, 99.9 percent of the time there is another way.  For the 0.1, tell the customer its unsupported – Hosk

Other Options

If I can’t disable the subgrid (in a supported way), what other options do I have?

Disable buttons on subgrid

Scott Durow the Ribbon Workbench creator has an excellent article on disabling the add new button.  This hiding rule could be set on all the add buttons on the subgrid.

Show or hide the ‘Add New’ button on form sub-grid based on the value on the form

It’s worth reading this article just to look at the image which explains what buttons on the sugrid link to what buttons on the command bar inside the Ribbon Workbench.

In theory this option should work but it would involve setting up enable rules for all the buttons on the subgrid.

Hiding and Showing

Hiding and showing sounds like a kids TV show, actually I’m thinking of Show me Show Me

My initial thought was to disable the grid but in CRM 2013 sub grid doesn’t have a setDisable, which stopped my plan but looking at the CRM SDK I can see subgrids control does have a setVisible.

This line of supported code will hide the subgrid 

Xrm.Page.ui.controls.get(controlName).setVisible(false);

This shows it again

Xrm.Page.ui.controls.get(controlName).setVisible(false);

The code above worked and it did hide the subgrid, the problem I had was it looked odd because it left a big blank white space where the sub grid was hiding (not very well).

The other problem is sub grids load asynchronously.  I needed my code to work on the form OnLoad event but when it came to hiding the the subgrid it was loaded yet and would throw an error.

To get round this error, I would need to wait until the subgrid had been loaded, so I could subsequently hide it (which doesn’t seem right when I say that out loud)

I created this code to wait until the subgrid is loaded.

  function ShowSubgrid(show) {
        var Subgrid = Xrm.Page.ui.controls.get("ChildCasesGrid");

        if (Subgrid == null) {
            setTimeout(function () { ShowSubgrid(show); }, 2000);
            //if the grid hasn’t loaded run this again when it has
            return;

        } else {
            if (show) {
                ShowControl("ChildCasesGrid");
            } else {
                HideControl("ChildCasesGrid");
            }
        }
    }
	

This works but I don’t like having wait’s in code, particularly in a form load where you don’t want to add an extra lines running on a form load which usually takes a while and the form load performance is extremely visible to a user.

I am of the opinion to avoid waits in the code at all costs, if you have a wait in the code you have a bug/problem waiting to happen.  Most of the time its worth the effort to find an alternative solution and reduce the complexity of your code.

A wait in code is similar to seeing +1 in some code.  The code is working round a problem rather than resolving the cause.

When considering form loads in CRM, it’s probably comparable to the frustrating time it takes for a computer to boot up in the morning.  The time may only be a short amount of time but it feels about four times as long in real time.

Whilst a form is loading the user has nothing to keep them occupied so the time feels longer, try to keep forms loads as quick as possible.  Here is a blog post I wrote on performance issues

CRM 2011/2013 Investigating CRM Form Performance issues

QUICK BREAK TO LOOK AT CRM 2015 SP1 new GridControl stuff

Looking at the CRM SDK form events page, initially it loads the latest page for CRM 2015 and I noticed CRM 2015 SP1 has a new special Subgrid OnLoad event.

There is a new page Write scripts for subgrids, there is now a new GridControl and you can look Grid objects and methods to see the new cool things you can do

The Grid Onload method is cool but there are some other interesting methods I noticed

The grid has

  • getRows
  • getSelectedRows
  • getTotalRecordCount

From the Grid you can get do a getRows and from here there are some great helper methods in the GridEntity

  • getEntityName
  • getEntityReference
  • getId
  • getPrimaryAttributeValue

and other stuff which you should go and check out yourself

Back to CRM 2013 subgrids

After some developer brainstorming I decided to try putting the subgrid into a section.  The advantages of this is you can hide/show a section without having to wait for the form to load.

Another advantage is when you disable a section it hides itself much better, the form acts as if it wasn’t there at all, unlike hiding the subgrid which leaves a white space the same size as the subgrid.

To hide or show a subgrid you have to toggle the visible flag using the setVisible method

Hide

Xrm.Page.ui.tabs.get("tabName").sections.get("sectionName").setVisible(false);

Show 

Xrm.Page.ui.tabs.get("tabName").sections.get("sectionName").setVisible(true);

Plugin Option

Maybe the most straight forward to resolve this issue is to have a plugin which is triggered on change of parentCase field.  When setting this you could check to see if the child or parent case is a restricted case and throw a pluginException

Conclusion

The blog’s title is about disabling a subgrid but the goal was to stop restricted cases from being linked.

The benefit of Javascript customizations is they are instant because the code works on the client side.  Plugins are server side, so their is a delay in capturing and responding to the changes.

Javascript can often offer a better user experience because CRM developers can react instantly to changes in values and hide/disable fields.

Server side changes are less responsive and cannot guide the user in the same way Javascript validation code can but has to catch the values and decide whether to roll them back.  Server side validation can be more frustrating to CRM users because they have made the changes, only to find them being rejected.

In this scenario the plugin/server changes are in one place, where there are lots of Javascript code changes to do the same thing.

A key skill of a CRM developer is selecting the right customization for the right job