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

I have been writing performance test scripts for Microsoft Dynamics CRM 2013 over the last week.  I now realise the reason for the lack of blogs posts and information on performance testing with Dynamics CRM.  I am using Visual Studio 2013 ultimate Web Performance and load tests and its frustrating, slow, difficult.

The main difficulties arise from the number of guids used in CRM.  To move the scripts from one CRM organisation to another, all guids need to be parameterised.

The CRM WRPC token stops scripts rerunning.  I took the easy option and turned off the token, instead of parameterising the token.  Read more here – What is the WRPC Token?

Microsoft released the CRM Performance toolkit, backwards compatible with CRM 2013.  The performance toolkit tests the default entities in CRM.  The good news is its a free performance testing tool, the bad news is its complex, making it difficult to change it to test your custom entities

CRM-Performance-Toolkit for CRM 2013/CRM2015 is released

CRM professional for hire

Hosk CRM Blog reader and CRM Professional Zsolt Zömbik is available for work now.

Why you should Zsolt

  • He reads Hosk’s Dynamic CRM blog
  • His name score extremely highly in scrabble
  • He has beaten Chuck Norris in an arm wrestle
  • When he runs over puddles, it doesn’t even ripple
  • He aims to be the first Microsoft Dynamics CRM professional to do a CRM deployment on Mars!

 One final point, he is ace at CRM.

Quote(s) of the week

The problem with troubleshooting is that trouble shoots back.” – Author Unknown
“Everything is theoretically impossible, until it is done.” – Robert A. Heinlein

People are born; leaders are made.
General Stanley McChrystal

Hosk Wisdom

People are born, CRM developers are made through knowledge of the CRM SDK and CRM project experience – Hosk

Article the week

become a CRM master 

Great concise blog with good advice to improve your CRM developers skills

Best of the Rest

How to create realistic Test Data for your CRM Project and why you should

Creating realistic test data for you project is great.  Create once, use many times.

Bad data can cause bugs

Good data can find bugs

XRM Strikes Back

Good article from CRM MPV Jukka about XRM

CRM Dialog and Custom Workflow example

An example of with a Dialog working with a Custom Workflow

Real time workflow or plugins

Scott Durow explains how Real time workflows work, comparing them to plugin performance

CRM 2013 – Why wasn’t an updated Custom workflow used by CRM?

I deployed a Custom Workflow but CRM wasn’t using it, find out why

How to remove dependencies to CRM Developer Toolkit

How to extract your customizations from the steel ninja grip of the CRM developer toolkit

Upgrading to Microsoft Dynamics CRM 2015? Here’s What You Should Consider

Things not to miss when deciding to upgrade to CRM 2015, things like, has your CRM become a beast!

Dynamics CRM How to access a QuickForm component via Jscript in Turbo Forms

I’m not sure why you would but here’s how

CRM 2013 – What is the WRPC Token and resolving INVALID_WRPC_TOKEN errors

WRPC token is generated every 24 hours to stop cross-site scripting, I bet you didn’t know that.

Using Actions in Microsoft Dynamics CRM 2015

I’m still not convinced by Actions in CRM. I keep reading articles thinking this time it will make sense

Read why Microsoft brought Adxstudio and why it’s good news

CRM 2013 – Understanding Solutions and how they work

Solutions in Microsoft Dynamics CRM give with one hand and bash you over the head with the other

Microsoft Social Engagement 2015 Update 1.2 is ready!

Social engagement continues to improve (which it needed to), check out the new functionality

Don’t just test the happy path

Developers should test the happy path, alternative path and the exception path otherwise you are giving bugs a place to hide

Case study featuring Unified Service Desk

The Unified Service Desk is awesome, why don’t more companies use it?

CRM-Performance-Toolkit for CRM 2013/CRM2015 is released

How to find Javascript files used in Microsoft Dynamics Forms

Find those pesky Javascript files

Get next case functionality for Dynamics CRM

Interesting read

Programming

how to be awesome part 1

Document integration – part 1: some ideas…

A Toolbox of Software Architecture Review Techniques. Part 1: The simplest thing you can do

What Led Amazon to its Own Microservices Architecture

other

morning pages – how to write them

Why you should write morning pages

How Con Artists Exploit Human Behaviour

16 Great Quotes For Software Testers

Shut Up, Sit Down, and Type

Previous top picks

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

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

Tips on passing MB2-703 – CRM 2013 Customization and Configuration Certification

I finally took the MB2-703 exam and passed, YIPPPEEEE

This is the 3rd time I have taken the customization and configuration exam because I have taken it for

  • CRM 4
  • CRM 2011
  • CRM 2013

Every time I take the exam, during my studying and preparation for the exam I always learn or understand how CRM works a bit better. The certifications involve studying new functionality added in each new release of CRM but my understanding is different and I focus on different aspects of CRM and try to understand how the internal CRM mechanics are working and I wrote articles like these

CRM 2013 – When should you create a custom activity entity?

CRM Entity ownership – How do you decide?

To see all the articles, questions and videos I have created for the CRM 2013 customization and configuration certification click the link below

https://crmbusiness.wordpress.com/mb2-703-crm-2013-customization-and-configuration-certification/

I have also createde some links to some good free articles on subjects on the exam but alas there isn’t many links there because I started to late with that idea

https://crmbusiness.wordpress.com/mb2-703-crm-2013-customization-and-configuration-certification/free-links-mb2-703-study-guide/

It’s worth the effort

The value of the certification comes from the studying and reading for the certification rather than having the certification.  It was a great motivator to learn the new functionality because to make the exams different there is usually an emphasis on new functionality, which is logical because otherwise the exams could be quite similar.

I find it useful to refresh my knowledge on areas I haven’t used for a while, forgotten and the new functionality which I may not have used yet.

Learning the information to a level you can pass a certification does reinforce the information and helps it stick in your mind.

I have written before

CRM 2013 – Why you should take and pass the Configuration and Customization Certification

A quick recap  why I think it’s worth studying for the latest CRM certifications

  • Learn how the new functionality works, particularly it’s limitations
  • Study CRM functionality you don’t use very often
  • Refresh your knowledge on CRM
  • You get a broad knowledge of CRM

My process of studying

Read the MOCS (Microsoft Official Circiculm)

You can find the link to the MOC’s for all the certifications here.  The MB2-703 MOC link is below.

MB2-703: – Microsoft Dynamics CRM 2013 Customization & Configuration

The MOC should be the solid base to build your studying for the certification around.  The MOC covers all the areas which will be in the exam and unlike CRM 2013 books, only focuses on the areas which will be on the exam.

Read articles on the subjects

The MOC’s are great but they can be a bit dry and I like to read articles on areas of the exam.  Articles are small bite sized chunks with the added benefit of usually containing examples and screen shots.  The real world usage of CRM 2013 functionality is very useful for understanding how the CRM 2013 functionality can be used and limitations

Take notes

Taking notes is a good way of highlighting the important points for revision and condescending the MOC’s, blog posts and other sources of information into a smaller collection, which you can revise from.

Using CRM 2013 trial

There is no better way to learn the functionality of CRM 2013 than by using it.  If you are fortunate you will use CRM 2013 every day in your job, but there are still areas you don’t use very often, but make sure you know how they work rather than just the theoretical knowledge of how they work.

Tips on passing the certification

New Functionality

Study the new functionality added into CRM 2013

  • Business Process Flow
  • Business Rules
  • Access Teams

Use CRM 2013

Don’t just read and study about CRM 2013 topics, but actually try it out with a CRM 2013 trial

  • This will give you some practical knowledge/experience of the functionality
  • It will help you understand how it really works, which isn’t always the same as it says in the manual
  • You learn how it doesn’t work (important, particularly for the exam)
  • It creates experiences and visual images which will help you recall information in the exam
  • You will have experience of using the functionality, which is useful for your job

Write your own study notes

Going through the process of making notes when reading the MOC’s or articles on the exam subjects I would make notes.  The process of taking notes means you have to understand the material and select the key points.  To do this you have to actively think about the topic and subjectively understand it to the key features/limitations.  I believe this will help you learn and increase your understanding.

The benefit of taking notes is you can use them to study with later.

Blog about the CRM 2013 functionality

Teaching and explaining about a topic makes you learn and understand the topic in more detail.  This will give you a deeper understanding of the functionality.

I found writing about the security and business rules very useful

CRM 2013 – MB2-703 – Business Units and Security Roles Study Information

CRM 2013 – Understanding Business Rules

If questions came up about these topics I had a very good understanding and could work out the answers

Exam tips

 

Book the exam so you have a deadline

This is a great motivational tool and will stop you keep putting off taking the exam.

Create some practise questions or use mine to practise

If you are studying with someone else both create practise quesitons and notes, share them with each other

There is some practise questions you can find on my blog post below

https://crmbusiness.wordpress.com/mb2-703-crm-2013-customization-and-configuration-certification/

Study Notes

Create your own study notes, you will be learning and reinforcing the information by creating the notes and reading study notes is quicker and easier than MOC’s or blogs

My study notes are here

CRM Chat Study notes can be found here

CRM GEEK for CRM 2011

The study notes are very useful, 46 pages of good notes about the CRM 2011 Customization and Configuration exam. http://www.crmanswers.net/2014/01/crm-2013-mb2-703-exam-my-experience.html

Exam Techniques

  • Get there early, sometimes the test centers are in odd places which could take some time to
  • Take your time in the exam (you will have plenty)
  • On each question, first eliminate the answers you know are wrong, usually there are some obvious answers which are wrong.  This will leave you with a smaller choice
  • Review all the questions, just to make sure you haven’t made any silly mistakes

CRM 2011/2013 – use the debugger console to enabled/disable controls on a form

I was trying to fix a small bug but I was getting bogged down with the business logic (which I didn’t need/want to change) on the form.

The problem was there was lots of business logic which kept disabling the fields I wanted to change.

I tried briefly to understand the business logic but it was complex and detailed and I wasn’t really interested in understanding the form logic and/or briefly amending the JavaScript onload.  All I needed to do was to enable an optionset on the form, which would enable a ribbon button.

So it’s time for a bit of off the cuff hacking

I loaded the form

Press F12 to bring up the debugger window

You can use the console to manipulate the fields and enable/disable certain fields.

You have access to the CRM JavasScript objects

So I used the Xrm.Page, selected the control (not the field attribute) and did a setDisabled(false); which enables the control.
Xrm.Page.getControl(customerid”).setDisabled(false);
This didn’t enable the ribbon button because although the JavaScript function which is used by the ribbon button (e.g. the enable rule for the Ribbon button) the ribbon hadn’t been refreshed.

So I used the console to do a Ribbon Refresh

Xrm.Page.ui.refreshRibbon();

Fantastic, now my field was enabled and the ribbon button was enabled and ready to be pressed.

 

Other uses for F12 JavaScript debugger is to get the guid of the record, which I did on this blog post

 

Browser bookmark

An alternative to bringing up the F12 debugger is to create a bookmark, this will enable you to pass javascript into a form before loading it.

The blog post below created a God Button, which enables all fields

http://www.magnetismsolutions.com/blog/paulnieuwelaar/2014/07/29/activate-god-mode-in-crm-2013—don-t-let-your-users-see-this

 

This blog post will talk you through the logic and is the first part in a series of blog posts on the subject

http://blog.sonomapartners.com/2014/01/crm-2013-javascript-bookmark-series-part-1.html

 

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

I found myself writing this tried and tested code, which I have written many times before

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

before you can get a value from the entity attributes you need to check the field is included in the list of parameters. I traditionally use to do this using entity.Contains(“fieldname”), if the field specified exists in the list of parameters it will return true. The reason this works is because CRM doesn’t pass null values in the parameter list, so if its null it won’t exist.

Often in code you will lines and lines of Entity.Contains code, checking the field exists before assigned the value.

Is there a better way

I remember an excellent post featured on CRM MCC Guido on his blog CRM Answers
Entity.GetAttributeValue and ActivityParty

The article was about using Entity.GetAttributeValue and in this blog he linked to an excellent and detailed explanation of how Entity.GetAttributeValue works from CRM MVP Dave Berry

Entity.GetAttributeValue Explained

I had a classic case of reading how to do something in a better way but automatically doing it the way I always did it, except I now had a chance to do it differently and that’s what I did.

 

What is the Entity Class

The Entity class is the base class in CRM development and this class holds some key details about what entity it is

LogicalName – logical name of the record e.g. contact,account, lead
Id – ID of the record

The other important values are the Attributes. The attributes are a collection of attributes, e.g. all the fields in the entity/record.

What is the difference between an entity and a record

Entity

The entity e.g. account, contact, lead.  This is the design of an entity but doesn’t hold any values.  I would liken this to an object and an instance of an object.

Record

A record is an entity but with values, e.g. someone has created a New contact and this creates an instance of an entity (the design) and makes a record with individual values (e.g. name = Hosk, description = marvellous);

It uses object to enable it hold the various different variable types possible, it will mean if you are using late binding you will need to cast the values into the type you are expecting.

 

Trying Entity.GetAttributeValue

I thought I would try it out because it would save me wrapping if statements round things and seemed a better way to do things.

initially I removed the contains if statement and I got a variable doesn’t exist type error, hmm this isn’t meant to happen , I then realised it was a user error

I actually hadn’t typed it in but just removed the if
title = (string)entity.Attributes[ “title”];

I then added the proper method
title = entity.GetAttributeValue(“title”);

 

When developing I usually test my plugin code by making my plugin code take a iOrganisationService instance and an entity and put these in a separate class. This means the plugin can call my class but more importantly it means I can call this class by creating an iOrganisationService and an Entity object and not worry about any of the other plugin stuff. This enables me to call my new code in a console app which creates an IOrganisationService connected to the Dev environment and then do a service.Retrieve(“contact”, guid, columnset);

So I kicked of my console app and this retrieved a contact record and selected the title record and in this case the value was null and the code set the string title variable to null.

 

So I used this to retrieve a OptionSetValue and string and it worked fine.

it’s important to note this will bring null back if there is no value or the value is null.

Also remember for some types it will bring back the default value if something doesn’t exist and this might not be what your code is expecting.  In Dave’s blog he has a handy table

Type Return
Numerical (int, decimal, double) 0
Boolean false
DateTime DateTime.MinValue
Guid Guid.Empty

 

Why isn’t Hosk using Early binding

A question you are asking is why is the Hosk using Entity instead of an early bound class like Contact or Lead.  Great question, I’m glad you asked 🙂

The reason I am using the entity class is because the plugin was going to run on the contact and lead entity and maybe some other entities in the future.  The fields had he same name on the different entities, this enabled me to write the code (using Entity) which would work on both Contact and Lead.

Hosk’s Top CRM articles of the week 3rd October 2014

Thumbs up for friday everyone

Articles of the Week

I will add this as one of my top articles, it’s not really an article but it’s very useful because the blogs on the list are excellent

The top 25 CRM blogs

 

This article from Guido is great, it takes a question from the forum, an answer from CRM MVP Scott Durow, followed by some hard work by Guido to create the full solution, great work.

Check if a User has a specific Privilege

 

I will add another because I can, it’s from the snooze Berry, Dave Berry.  It was written when Dave use to blog (pre snooze), although I have been informed from the great Berry himself he is busying doing great things with TypeScript and CRM

Entity.GetAttributeValue<T> Explained

 

Best of the Rest

 

Interesting article showing  you how to compare 2 lines in your fiddler trace

Comparing Sessions in Fiddler

 

A quick definition on business rules
CRM 2013 – Quick Guide to Business Rules

 

Add CRM DLL’s via the internet not you local drive

Don’t load CRM dll’s from the local folder, go to the internet

 

How to convert HTML to plain text for an email with a plugin

CRM 2013 – Convert Email HTML to Plain Text

 

The error and the solution

Assembly generation failed — referenced assembly does not have a strong name

 

Great article from Guido with a reference to Dave Berry

http://www.crmanswers.net/2014/09/getattributevalue-activityparty.html

 

An error caused by Odata query with null guid value

CRM 2011 – UnRecognized ‘Edm.Guid’ literal ‘guid’null

 

Are people starting to like Microsoft again?

Common things to check if your CRM is down

Microsoft Dynamics CRM not working? check these common causes

 

Hosk learnt a few things whilst reviewing javascript

CRM 2011 – Things learnt when reviewing Javascript code on form loads

A quick start to getting started with fiddler

Getting Started with Fiddler and CRM

 

A tool you can add (at a cost) to performance test CRM 2013 using fiddler

Performance testing with stress Stimulus in CRM 2013

Timers in CRM 2013 and ways to use them

The Best Little Microsoft Dynamics CRM 2013 Feature You Might Not Know What To Do With: Timers

How to debug those pesky ribbons
CRM Ribbon Problems

 

A new CRM 2015 feature

Nested Quick Create in Microsoft Dynamics CRM 2015

 

Using goals to schedule a daily job, very clever

Scheduling Recurring Workflows for a Nightly Processing Service

 

CRM 2013 interview question and things to consider

CRM 2013 Interview Question – What things should you consider when choosing between CRM online or on Premise

 

Great description of leads

Leads are like Zombies

 

CRM Exams are reduced in price until December

15 percent of CRM exams until DEC with these codes

 

How will Microsoft Social Listening sell?

 

Quick Guide – What are Rollups in CRM 2013

great idea allowing people to write their own help, good listening Microsoft

Write custom help in CRM 2015

Question on the Hosk CRM Career blog

I have passed MB2-703 should I take the equivalent CRM 2011 certification

 

OTHER HOSK STUFF

Watch out for career climate change

Don’t be afraid to ask stupid questions

Are people starting to like Microsoft again?

How will Microsoft Social Listening sell?

CRM 2011/2013 – Ribbon problems

The investigation and problem I experienced where in CRM 2011 but I think it would be the same in CRM 2013, I had a problem with the ribbon javascript but I didn’t have a clue where it was because I had never seen a syntax error in the Javascript ribbon.

I put a debugger statement in the ribbon, so it would drop into the debugger.  The reason you  put the debugger statement into the Javascript code is because when the ribbon is loaded it is loaded in dynamic Javascript script block, this means when you press F5 it creates a brand new script file and you won’t have time to put a breakpoint in it if you bring up the debugger by pressing F12.

 

So I put my debugger line in and then the code hit my various display/enable javascript methods and I could step through them but the syntax error kept appearing.

I still wasn’t sure where/what the problem was.

I pressed F12 to bring up the debugger and this was bring up a syntax error

syntax error

I turned on fiddler and found on one of the calls I was getting a nasty red triangle on one of the calls.

The thing which kept bugging me was it was a syntax error

I could see the code and it looked fine (although syntax errors are not obvious to the naked eye). The file compiled in Visual studio and pressing F12 to get the debugger didn’t throw an error, so this would suggest the javascript syntax was not the problem

 

frustrating

I fired up the Visual Ribbon Editor for CRM 2011/2013

In the Visual Ribbon Editor here you have display rules, enable rules and action.

There was no disable rule

there was an enable rule and an action rule which both called a javascript function, you can see below

ribbon enable
ribbon action

Slowly something clicked, the error was trying to call the action, why was it calling the action whilst loading the form. Logically the ribbon has to make sure the Javascript method exists so when the user presses the button something will happen but why was it triggering a syntax error whislt loading the ribbon?

Syntax error, ribbon load…..hmmmmm

Look at the two rules, although I’m not showing you the actual file, look at the position of the library and the function boxes!

Finally after hours and dragging more eyes to the problem, my colleague found the problem by exporting the Ribbon xml, hazaaar the problem was obvious

The library and function values from the enable rule had been copied into the action rule, only this didn’t work because the function and library boxes are in different places.

He found the library – which should be the javascript library was pointing to a function.

Ribbon object not found

A new day a new ribbon problem.  Today on one of the forms the ribbon wasn’t loading and I was getting an error

 

SCRIPT5007: Unable to get value of the property Ribbon ‘value’ of undefined or null reference

 

The first thing I checked was to see if the function and library values were correct, they were.

In the Javascript files we use we build up the names spaces so the function calls are like this

Hosk.Functions.Account.Ribbon.NewAccount()

To find the problem I had to put debugger statements in the enable/action javascript rules and walk through them.

 

Eventually I found one where Javascript file hadn’t been loaded, so when it it was trying to call a function the javascript file was loaded, the function didn’t exist and we got a null reference.

 

CRM 2013 – Convert Email HTML to Plain Text

I have had this request from a few customers over the years and it’s converting and using the description of an email is trickier than you initially think it will be.  This is a question which often appears on the CRM forum quite regularly as well.

The reason for this is although the email looks like plain text when you see it in CRM, when you get the value of the Email entity description (main body of the email) you will also get all the HTML tags.

The scenario I had when I was doing this was the customer wanted to convert an email into a case and get the values from description.

So to do this I had to strip out the HTML tags and a few other things, which I did using a plugin

if you have to do this here a couple

This blog post is excellent

http://ashwaniashwin.wordpress.com/2014/04/16/convert-html-to-plain-text-for-copying-email-message-in-crm-2011-2013/

C# code

http://aliraza.wordpress.com/2007/07/05/how-to-remove-html-tags-from-string-in-c/

A sample plugin

http://blogs.msdn.com/b/ukcrm/archive/2008/07/10/converting-html-e-mail-to-plain-text.aspx

 

Recently I saw Steve Green had created a CRM Video going through the process and  I thought I would promote the video on the blog because he also has a link to the code here https://dl.dropboxusercontent.com/u/4041841/CRMDemo2014.zip

 

 

I would also recommend anyone who wants to learn CRM development to go through Steve’s other CRM videos, many of them are in CRM 2011 but the code would still work in CRM 2013.

CRM 2011 – UnRecognized ‘Edm.Guid’ literal ‘guid’null’

A user had reported this error and the Hosk was tasked to investigate

 

UnRecognized ‘Edm.Guid’ literal ‘guid’null

EDM.guid error

 

What made investigating this error more tricky, was it occured only when a new record was created.

I couldn’t seem to catch a debug message on the form onload because I think it creates new javascript files, so if you do put a breakpoint on a file it’s not used.

I did some investigation using the internet about this error

This blog had a similar error before to do with dates and json queries

 

I found this page on json fields

Edm.Guid Literal form of Edm.Guid as used in URIs formatted as a JSON string

 

I think the problem was definitely related to an Odata query and the code I was looking at used the Rest framework.

 

Fiddler to the rescue

I turned on my trusty Fiddler to try and capture what was happening.  I ran the create form, got the popup error and then in Fiddler logs I could see last line had a nasty red triangle with an exclamation in it.

I found the Odata query and could see it the filter in the oData statement was null, which meant it was trying to retrieve some a single record but was passing a null guid.

filter=field%20eq%20guid’null’

I searched the F12 debugger using the select statement to find where the code was.

The code was actually being triggered from by a ribbon button and the evaluate javascript.

 

Debugging a ribbon

Debugging a ribbon can be a little bit tricky because you can’t use the F12 debugging method and you have to put in a

debugger;

when the browser hits this, it will ask you  if you want to debug the code in Visual Studio, you say yes please.

You will now be able to step through the code to find out the problem.

Here is the code (changed to make it generic)

 

if (selectedId == null)
selectedId = Xrm.Page.data.entity.getId();

if (typeof selectedId == "object" && selectedId != null)
selectedId = selectedId [0]. id;

var fieldResults= NttDataUk.Functions.Rest.retrieveMultipleSync("contactSet",
"first name,last name,statuscode",
"contactId eq guid'" + selectedId + "'");
if (fieldResults== null) {
return false;
}

 

So the problem was it was getting the guid of the record but new products don’t have guids because the guid is only created when the new record is saved.

The actual error was being generated by the Odata query which tried to get a record using a guid = null.

Solution

There are two solutions to this problem.

Change the display rule for the ribbon button to only display for records in a form state which doesn’t equal create

display rule ribbon

The other solution was I could add in check in the Javascript, to add a check to see if selectedId == null then return false, this would show but not enable the button.

The advantages of not displaying the button would also save a little bit of time drawing the button.  You should consider I changed the display rule and not the enable rule because I felt there wasn’t any point in showing a button you can’t use.

 

CRM 2013 – Business Rules work in pairs because the condition is AND and not IF

CRM 2013 brought in a new features called business rules, if you want to read more about business rules click on one the articles below

CRM 2013: Understanding Portable Business Logic

Become a Pseudo-Developer with Business Rules in CRM 2013

Business Rules in Microsoft Dynamics CRM 2013

A quick summary of business rules is they allow you to do client side validation without using Javascript, which allows non developers to create, edit and maintain them.

As an added bonus they also work on CRM tablet.

In some ways they are like mini workflow, except workflows run at entity level, Business rules run at field level and are triggered by field events.

Business rules are easy to create and they have two parts

Condition (The IF)

Action  (error message, set field value, enable/disable field, show/hide field or section, set requirement level of field)

Here is a screenshot of a business rule

Business Rules 1

  • Validate data and show error message
  • Set field value
  • Enable or disable field
  • Show or Hide a field
  • Set field requirement levels

Limitation

When creating a business rule to hide a field/enable a field, you test it and and it works, suddenly you realize the field is not being enable/disabled, the opposite action does not occur.

The reason for this and the reason business rules currently work in pairs because business rules condition logic only has AND logic and not IF.   This may change in the future but it’s a limitation at the moment, which can catch people out.

An example is if you created business rule to check if Account Name has a value, when the field contained a value you could show the Account number field

If the person then deleted value in the account name the account number field would still be visible because it had not been hidden again

Business Rules 1

 

In this case you would need to write another business rule to hide the Account Number if the Account Name doesn’t contain data.

 

So remember in most cases you will need a pair of business rules to undo the actions of another business rule