A few interesting things I learnt from the many convergence 2015 tweets

The main thing I learnt from convergence is people tweet too much about convergence 🙂 Particularly the CRM MVP from new Zealand – nzCRMguy , who I’m sure broke my twitter feed at one point.  To be fair he did tweet a lot of excellent tweets, it was just rather frustrating to read them a little bit at a time.

I don’t deny this blog post is also part frustration at having to watch convergence 2015 from twitter rather than being their in person, I’m sure if I was there I would be tweeting my head off.

You will probably read a lot about convergence and the new functionality coming in the next CRM 2015 release but here a few things I found  interesting.
The tweets come from
CRM MVP Jukka Niiranen
CRM MVP Mark Smith

CRM 2015 – Themes and branding

My initial thought was woohooo.  Changing the colours and branding is an often requested by customers and the previous way was to change an image file on the server.  This was unsupported (but mostly harmless) change.
One reason changing CRM was useful was customers wanted to distinguish betweeen their different environment e.g. DEV, TEST, PROD.   The branding feature should easily allow this to happen

Most Recently used

Any changes to the CRM 2015 navigation are welcome because it is one of the most difficult and frustrating layouts I use.  It’s hard to find things and difficult to navigate.

Most Recently used looks like a bit like favourites but it is a list of the recent records you clicked on.  This should be useful and speed up navigation

New Nav Bar

Yes the NAV bar has been updated, this looks a lot more user-friendly.  It’s a big improvement because it shows all the options on one screen, so you don’t have to scroll about to try and find the option you want.  Well done to Microsoft to listening to the feedback and improving the CRM 2015 navigation

Solution packaging

I like the sound of packaging data inside a solutoin
Solution + data + import actions

Unmanaged and managed solutions

The order matters and unmanaged customizations can be overwritten by a managed solution in some circumstances.  To be honest I’m not quite sure what this means but what I did think was this doesn’t sound good

Hosk CRM DEV Tip – Always filter your queries

Is important to keep good habits and keep your CRM solutions zipping along and in most CRM projects there will lots of queries retrieving records related to the main record.

CRM queries should like Bruce Lee one inch punch.  Mean and Lean with no wasted actions

The one inch punch is so awesome it has it’s own wiki page

The one-inch punch is a punching exercise from Chinese martial arts (kung fu) performed at a range of 0–15 cm (0–6 in). The one-inch punch was popularised by actor and martial artist Bruce Lee. It is designed to improve punching power and technique.

Your CRM code should be as simple as possible 

CRM code and CRM queries should be as simple as possible but not simpler

Last year I was doing some optimization and one of the main culprits of poor performance was due to queries not filtering and returning all rows.  There were examples of no filtering in OData in Javascript and plugins.  You can read more about my investigation into CRM performance here

What to look for

  • new ColumnSet(true))
  • Odata queries with no “filter=”

what are the consequences of not filtering your queries, apart from being on Hosk’s naughty list

Poor performance

The downside of not filtering your queries is you are returning fields you don’t need, this will cause the query to take longer to run and bring down more data for every row returned in your query.

The bottom line is your queries are going to take longer and the more rows you return the worse the performance.

Updating all fields which can trigger more actions

When a query has selected all the fields for an entity another mistake the CRM developer can make is to update the record which updates all the fields in the record.  This can

  • Creating confusing audit trails with fields being updated but not changed
  • trigger workflows and other plugins

I have had some conversations with customers asking why the audit record was saying a field had been updated but no one had changed the field.

The triggering of other plugins/workflows can not only have contribute to poor performance but also trigger new records and values being changed.

Code review shaming

Peer reviews are a great way of stopping poor code like this entering your code.  If the CRM Developer knows the code is going to be code reviewed they are less likely to take shortcuts, write poor code because they know it will be found in a code review.

If a CRM developer does write queries without filters then the code reviewer knows they need to be watched because they are a lazy coder.

Lazy coding

In my blog code Bad code is like a virus, don’t get infected I mention the broken code theory.

If the no poor code had been checked in, the CRM developer would see the code checked in is a high standard, the developer understands the code in this project should be a high standard and will follow the herd checking in high-quality code

If the code repository has been infected with bad code the CRM developer will see it’s OK to check in poor quality code, the easiest action for the CRM developer to take is the quick and easy fix, which is of lower quality and will cost you more time in the long run and make it harder to change the code in the future.

I believe you need to keep the coding standards of a project as high as you can and ensure CRM developers adhere to best practise.  Once bad code gets into source control then you will soon find it starts to grow as other CRM developers check in similar quality code.

Finally

There is no excuse to not filter your queries so don’t do it.

 

Why all developers should be friends with a cardboard developer

I read an article  about a development team who used a cardboard developer.  The team had acquired a life-size cardboard person who they welcomed into the development team.

If anyone in the team had some code which wasn’t working, before asking another developer to sit with them to look at the problem the person had to first get the cardboard developer, stand him next to them, explain the problem to the cardboard developer, run through the code with him to see if he could help see the problem.
I have also learnt this process is known as Rubber duck debugging from the excellent book
The funny thing about this story is quite often the cardboard developer would help resolve the problem.
How exactly does a cardboard cut out help solve development problems and why aren’t companies deploying armies of them.

Stop! walk through the process step by step

The truth is people can often solve their own problems, once they understand the problem and walk through it.
This is what I would term as
can’t see the wood for the trees
This is a saying which regularly gets said, but I’m not sure everyone understands what it really means
Here is an explanation

Meaning: If you can’t see the wood for the trees, you can’t see the whole situation clearly because you’re looking too closely at small details, or because you’re too closely involved.

In terms of CRM development you can get  absorbed in a problem, the methods you have already tried to resolve it, you can get to a point where the CRM developer stops thinking logically about the problem.  For coding problems in particular you can get too close to the problem you forget to use a systematic process of trying to resolve the problem.

A classic example of the cardboard developer – Grumpy IT person

I’m sure many people have called the IT person in their organisation only to find they have given him the role of cardboard cut out.  You calmly explain the problem to the IT person (who is usually grumpy grumpily) to come and try and solve your problem.

When the IT person comes to your desk you go through the steps and it works perfectly and the IT person grunts and goes back to his warm nest away from troublesome users.

Many times I have asked someone to look at a problem and then as I was explaining it to them I instantly knew the answer.  It’s a similar sensation to not hearing someone, saying pardon and then your brain belated tells you what they said.

Why does the Cardboard developer work?

The reason the cardboard developer or any inanimate object works (it helps if it resembles a person or you feel stupid explaining your problem to an apple) is when you explain the problem to someone/something you

  • You have stepped back from the problem, you have stopped to think
  • Go through step by step
  • Explain what you want to happen
  • Explain what is happening
Developers often have to do the same/similar tasks many times they often
  • Engage autopilot
  • Stop thinking and just do
  • Miss steps/Take shortcuts
  • rush

Why should you use the Cardboard developer?

The main reason you should try using the cardboard developer is so you stop wasting other developers time when you could resolve the problem yourself.

Developers need to concentrate for a prolonged uninterrupted section of time (hours) to create a coding solution, this process involves concentrating on a problem with lots of trial and error.  Breaking this concentration for a developer to come and stand by you whilst you resolve the problem yourself can be frustrating for the developer who you have walked round the office and embarrassing for yourself for wasting the developers time.

To avoid wasting developers time I would advise getting up from your desk, going for a walk at lunch, making a cup of tea.  The act of stepping away from your computer will allow you to look at the problem with fresh eyes.

Make sure you use the Cardboard developer to go through a problem first before asking someone else.  I’m not advocating you sit and suffer with a problem but you should make sure you can’t resolve the problem yourself first.

This blog describes why Developers should not be disturbed

Why programmers work at night

or this graphic shows the process which I got from here

Today I used the Cardboard developer

Everyone has to use the cardboard developer and today I should have used the cardboard developer but instead I brought over Sir Les (senior CRM Developer) over to my desk.

I was creating a new development organisation.  I had imported a number of managed and unmanaged solutions.

The next stage was to import some data, I selected the file, press next a few times but then was puzzled why the entities weren’t in the drop down list?

I couldn’t think of any reason why entities don’t appear in drop down lists for importing?

So I got senior developer over.

The act of having someone looking over your shoulder suddenly gets your brain working with more focus.

Have you guessed the problem yet?????

Yes, suddenly it came to me,  I had imported some unmanaged solutions.  Unmanaged solutions need to be published (managed solutions are published automatically).  To understand the intricacies of solutions read my blog post – Understanding how CRM solutions work

Sir Les of CRM Shire was thanked and sent back to his desk, he helped me resolve the problem without doing anything.

Next time I will try explaining it to the cardboard developer before wasting a real developers time.

Check out the Dando the box man adventures

Here and here

CRM 2015 – resizing the social tab

CRM 2015 has social tab which is confusingly labelled conversation tab on the case form.

The social tab is a great spacing saving component because it uses tabs, so you can quickly move between activities, posts and notes.

The social tab works pretty well, allowing the user to quickly view and create activities, posts.

The social tab was initially created in CRM 2013 and people liked it but got frustrated because they couldn’t customize the social pane.  Read about it below

CRM 2013 – The social tab is good but would be better if you could customize it

My personal view is we should be grateful for social pane and view it as a bonus.  It’s one thing to create the social pane it’s a whole different thing to create a configurable social pane because everyone would want it to work differently.

Conversation tab and space

I was this question about the social tab

Any suggestions as to how I can reduce the depth of the Conversations Tab in the case form? I have tried properties, etc.

social tab 3

I am putting the answer here but it wasn’t me who found it but Fritz (a CRM developer)

The solution

This one is odd but the workaround to this is straightforward. The Conversation Tab field is essentially the Notes. What I’ve done to unlock the row layout is:

#1 Delete the existing Conversation Tab:

social tab 1

#2 Inserted the Notes in its place (un-ticked the display label option) and then under the ‘Formatting’ tab there should be now the row layout.

social tab 2

 

 

 

 

Hosk’s Top CRM Articles of the week – 13th March

 

Article of the week

Monitoring Rollup field values using workflows

A great article from CRM MVP Jukka.  Not only does this give you a workaround to the annoying gotcha of Rollup/calculated fields not triggering workflows but it also shows you how to schedule a recurring workflow.

Best of the Rest

CRM 2015 – Why filtered views are useful

A Hosk article showing why Filterd views are awesome

Custom help using word in CRM 2015

Another Great article from Benitez who has written some excellent and detailed articles on the new CRM 2015 functionality

Tip #342: Demystifying pop3/smtp for CRM Online

How to get Gmail/Yahoo mail and other mail clients to work with CRM.  It’s something many people have thought of but never done.  Maybe that’s just me

Bad code is like a virus, don’t get infected

Don’t let anyone check in bad code, it can only lead to more bad code.  The Broken Code theory

Your Code as a Crime Scene

An interesting article from the book with the same name.  There is a youtube video on the topic and a couple of  free test chapters

introdesign decay

The Implications of Cascading Ownership

Cascading ownership can be tricky to understand and sometimes sneak up on you with it’s implications.  This article should help you learn about it

How to find Javascript files used in Microsoft Dynamics Forms

Hosk article on how to find what Javascript files are being used with a CRM Form

Using Routing Rules in MS Dynamics CRM 2015

Learn how the new routing rules work in CRM 2015

What is a finite state machine and why is it like CRM 2015 Custom State Model Transitions

A finite state machine is an interesting way to arhcitecture your code, a useful way about thinking about state transitions.  CRM 2015 has new functionality allowing you to configure what status a user can move to.

Memory management for Dynamics CRM in a virtual environment

Interesting article

hide sitemap areas based on security role

This isn’t supported but it’s an interesting article and you might need it in desperate times.

Last Best of

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 – Why filtered views are useful

If you have been a CRM developer for a length of time then you will certainly come across filtered views and they are useful and definitely something you should learn more about, particularly if you are going to be writing reports or accessing the CRM database directly.

The CRM database can be viewed and the data used but never changed directly – Hosk

This quote means you should never change data directly on the SQL table, below are a few key reasons why
  • Direct changes to the SQL table are unsupported, this will result in Microsoft offering no or limited support if your CRM installation goes wrong.  You can read more about why you should not create unsupported changes here
  • When you use the CRM SDK to change a value it could update other fields and values, direct changes to the SQL will not
  • There is no validation on the SQL tables,  you could easily put in an incorrect value
  • If you write SQL stored procedure directly against the CRM database tables this could stop working when a rollup or service patch is applied to your CRM organisation

You should be of the opinion directly changing values on the Microsoft CRM database is a big no no

Best practice is to avoid accessing fields directly from CRM tables, the database structure, tables and fields could all change in future releases, rollups and service packs.

So what is the alternative to accessing CRM data using SQL if you shouldn’t access the data directly?

Microsoft have created a filtered view for each database table and Microsoft will make sure these work even after future releases, rollups and services packs.

Start with the CRM database

The database has an odd status for CRM developers, we all know it’s there and in many ways Microsoft Dynamics CRM is at its core just a database for customers to store and use their precious data.
CRM developers know there is an SQL server database there and you may have installed CRM or written some SSRS reports using the database.
CRM developers are taught all interaction with the CRM data should be done using the CRM SDK or OData/Rest queries if using Javascript.
Basically no direct access to the database, this is highlight if you look at this great article on MSDN – Microsoft Dynamics CRM Extensibility Architecture, below I have taken the diagram.
Microsoft avoid tight coupling and unmanaged complexity (one of the deadly sins of complex code – read more The problems with complex code and complex CRM Customizations) by limiting access to the database to
  • Data Access Platform
  • Filtered SQL Views
CRM online doesn’t allow any access to filtered views, the reason (obvious when you think about it) is because you do not have access to the CRM database, which is quite a limitation to the reporting options for CRM online deployments because they will all have to be fetchXML.
In the (good) old days (warning Hosk you are starting to sound like an OLD CRM man) of CRM 2011 and versions of CRM below the CRM database use to have a base and an extended table for entity.  The base table had the out of the box fields and the extended table had all the new custom fields added.
so for the account entity
AccountBase
AccountExtended
In CRM 2013 (optional)/CRM 2015 (mandatory) the two database table structure was changed and merged into one database table.  I’m not sure what happens when you upgrade a database but I’m guessing the scripts in the background might merge the database tables, which is another warning why you shouldn’t write SQL directly against the database tables.

What are filtered views?

Filtered views have been around since the days of CRM 3, I’m happy to say I have never had to use a version of CRM below version 4.  I found this article written in 2006
The best and first place you should start looking for information is the CRM SDK (the Truth). The link below shows the names of the filtered views in CRM.
Entity schema name Entity type code Report view name Description
Account 1 FilteredAccount Business that represents a customer or potential customer. The company that is billed in business transactions.
AccountLeads 16 FilteredAccountLeads Represents the intersect table for the accountleads_associationrelationship.
  • Filtered views have the same name as the CRM table but with the word Filtered prefixing it.  Not all Entities have filtered views because some entities are system entities
  • Filtered views will be automatically created for any custom entities you create.
  • In CRM 2011 the filtered view contained all the fields in the base and the extended table.
  • CRM filtered views exist for individual activity types e.g. (email, task, letter, etc)

Why are Filtered views cool

 
You are probably wondering what is so special about filtered views, it sounds just like a view of the table.
Microsoft has created a create article called Use SQL and filtered views to retrieve data for reports, this has many of the benefits of Filtered views listed below

The benefits of Filtered views are

  • Filtered views won’t break after patches, services releases and maybe upgrades
  • Security is embedded in the view
  • All the column names are in lower case
  • Filtered views are automatically created and updated for custom entities
  • Datetime fields are held in datetime and UTC
  • Drop down values are held in filtered views

Filtered views won’t break after patches, services releases and maybe upgrades

Microsoft will support filtered views in future versions, rollups, service patches, upgrades.   If you write reports against a filtered view it won’t suddenly break when a rollup or service patch is applied, the report should work if you upgrade the version of CRM (that is a big if).  Microsoft can change CRM tables but when they do they update the filtered view to work with the changes.

Security is embedded in the view

Filtered views are created for CRM developers to use in reports.  Filtered views use the Microsoft Dynamics CRM security model, so data shown in a report using a filtered view would only contain the data the users can view in CRM.

Filtered views take uses security levels e.g. organisation, business unit, owner and field level and these only show the levels each individual user can see.

If you created a view created directly on the Microsoft Dynamics CRM tables then it would show all the data to all users.

Adam summarises this excellently in his comment

Filtered views enforce  security

All the column names are in lower case

All the column names in a filtered view are in lower case, so you do not have any problems with case sensitivity

Filtered views are automatically created and updated for custom entities

Microsoft is busy in the background and when you create a new entity or add fields to a custom entity or System entity, Microsoft automatically creates a new filtered view for custom entities and adds the new fields to existing filtered views.

Datetime fields are held in datetime and UTC

Filtered views have two datetime fields for every date time field you add.  One DateTime field and one UTC DateTime field.

The DateTime field holds the date time for the users time zone

DateTime UTC holds the time in UTC

Drop down values are held in filtered views

Option sets have two fields in a filtered view, one holds the value the other holds the string representation

One field holds the string value of the option set

Another value holds the number

If you had an option set field accountrating with an option set value set of Gold – 1.

accountrating = 1

accountratingname = “Gold”

Primary Key Field

The primary key field for each entity has  a field in the filtered view.
e.g.  contact filtered view would have the field contactid
My current dealing/problem
Filtered view has more fields it has a date field and date field UTC

Denormalisation

Thanks to CRM MVP Adam Vero for pointing this benefit out, he has an excellent blog which  you should read here.
CRM has added a few neat tricks and columns to the filtered view which makes them more useful than a view which will be supported in future upgrades/releases of CRM.
Mentioned above they included UTC field dates so we know they are already adding value to filtered view by having the same data but already converted, which saves the developer from doing this.
Adam mentions the filtered view has denormalization the data in the view but what does this mean, here is a wiki definition of denormalization
In computing, denormalization is the process of attempting to optimize the read performance of a database by adding redundant data or by grouping data.[1][2] In some cases, denormalization is a means of addressing performance or scalability in relational database software.
This means for lookup fields the filtered view contains two fields
  • Guid
  • Name
In most reports you will often want to display the name or the title of the related entity, this usually means you have to retrieve the extra data but in the filtered views they add the name field.

Problems with Filtered Views

One of the main problems with filtered views can be performance and they have been known to run slowly.
One of the reasons for the slow speed of filtered views is you cannot apply indexes to the tables. Another reason for poor performance is the filter view connects a number of tables together.
The security model can have significant impact on general CRM peformance and the filtered views performance will be slower if you have a large and/or complex security model.  A complex security model could include
  • Lots of Teams in different BU’s
  • Lots of sharing
You will quickly know if speed is going to be an issue with the report but the security advantages are definitely worth using filtered views to initially create the report.
If you cannot get your reports with filtered views working this blog has a potential solution
 This forum discusses how to speed up filtered views (there isn’t really anyway)

Summary

Filtered views are a great way to create reports in a supported fashion which won’t break in future releases.  The advantage of the security being applied to the report means your reports won’t show data the user isn’t mean to see.
The major downside is a common problem to all reports e.g. SPEED.  It’s common for reports to try aggregate lots of data and these reports can run slowly when using Filtered views.
The UTC date can be very useful and save you formatting the date
 My advice is to try the filtered view first because the advantages are great but if the report is too slow you have have to consider your options.

What is a finite state machine and why is it like CRM 2015 Custom State Model Transitions

A CRM Developer at work mentioned the term Finite State Machine and it was curious because I had never heard of this term.

The CRM developer mentioned it as something you would learn in your first year of computer science course.  So I thought I would investigate and the best way to learn something is to learn it enough to explain it to someone else.

So I will start will the description from Wikipedia Finite State Machine

A finite-state machine (FSM) or finite-state automaton (plural: automata), or simply a state machine, is a mathematical model of computation used to design bothcomputer programs and sequential logic circuits. It is conceived as an abstract machine that can be in one of a finite number of states. The machine is in only one state at a time; the state it is in at any given time is called the current state. It can change from one state to another when initiated by a triggering event or condition; this is called atransition. A particular FSM is defined by a list of its states, and the triggering condition for each transition.

Abstract ideas harder to grasp

I remember when I starting out as a Java Developer I found it difficult to understand abstract ideas, particularly Abstract classes and Interfaces.

I have also found abstract ideas are harder to explain to other developers, the main reason for this is because its harder to use scenarios to explain the idea because Abstract ideas can’t be compared to physical objects.  Reading the Abstract vs Concrete article on wikpedia, it describes the difficult comprehending abstract ideas

The type-token distinction identifies physical objects that are tokens of a particular type of thing. The “type” that it is a part of, is in itself an abstract object. The abstract-concrete distinction is often introduced and initially understood in terms of paradigmatic examples of objects of each kind:

Examples of abstract and concrete objects
Abstract Concrete
Tennis A tennis game
Redness The red coloring of an apple
Five Five cars
Justice A just action
Humanity (the property of being human) Humanity (the human race)

http://en.wikipedia.org/wiki/Finite-state_machine

This article is also interesting on Abstract versus concrete thinking

This brief article discusses why student find abstract ideas hard to understand

Understanding a Finite State Machine

The original definition on Wikipedia I found a bit ambiguous, the key to understanding something is you should be able to take the key concepts and explain them to someone in your own words.

The wikipedia definition I can take these key points

  • It can have only one state from a finite amount number of states
  • The machine can only have one state at a time, this is called the current state
  • It can change from one state to another
  • When a state changes this is called a transition
  • A state change is triggered by an event/condition

Whilst looking for articles on finite state machine I also found this excellent article on i Programmer

Finite State Machines

This article grabbed my interest in the first paragraph
Finite state machines may sound like a very dry and boring topic but they reveal a lot about the power of different types of computing machine.  Every Turing machine includes a finite state machine so there is a sense in which they come first. They also turn out to be very useful in practice.

I enjoyed reading this article and I started to understanding the logic of the finite state machine in more detail

  • The machine has an input which changes the state of the machine
  • The next stage depends on the current state and the input

Pictures are worth a thousand words on finite state machines

Below is a picture taken from Wikipedia here, the example is a finite state machine for parsing the word nice.  Notice if you price the correct letter sequence the state moves along.  You have the input of the character being typed in but it also checks the current state.

 

The example has

  • 4 states (Inactive, Active, Paused, and Exited)
  • 5 types of state transitions (Begin Command, End Command, Pause Command, Resume Command, Exit Command).
Here is a great example – Packman

Youtube Videos

State transition table

The other important concept of the finite state machine is the state transition table.  This is a table of all the possible states and the important concept is you have to include all the potential states and you cannot miss out any

The wiki article has a very simple state transition table for a

Current State Input Next State Output
Locked coin Unlocked Unlock turnstile so customer can push through
push Locked None
Unlocked coin Unlocked None
push Locked When customer has pushed through lock turnstile
Here is another example of a state transition table from here

here is a video

CRM 2013/CRM 2015 – Status Reason transitions/Custom State Model Transitions

When I was reading about finite state machine I was thinking about CRM 2013/CRM 2015 and the new functionality

Status reason transitions

this is also known as Custom State Model Transitions

It helps to understand the finite state machine to see how status reason transitions might work and how useful they can be.  The status reason transition doesn’t work exactly like the finite state machine but it’s in the same ball park

Before CRM 2013 you could change from any status reason to another status reason.

e.g. an incident could go from Open to Closed and completely missing out in progress.

With Status being able to move to any status this usually meant the status had to be programmatically moved and not allowed the user to directly change the status.

or

The status reasons would be removed and added using Javascript.

With Status reason transition functionality you can set what status reasons you can move to from your current status reason.

e.g. the user can only move to closed status from the status In-Progress.

Here are some good articles on status reason functionality

Define status reason transitions

Define status reason transitions for incident (case) management

Custom State Model Transitions

The custom state model transitions offer a great way to control status transitions without having to write lots of code and customizations

After reading about finite state machine it’s easy to see how you can use custom state model transitions to create this functionality and importantly it helps you think about the status for your entities and what available paths should be available to the user.

What I have learnt from learning about the finite state machine and the new state model transitions is when you are thinking about a Crm solution you should think about the entity statuses and the state transitions, what are the possible paths.

Its interesting to split up the design in

Input
Current state
Next state
Output

The more time you put into design of your CRM solution the better the code will be structured and less changes to design and code later on.