Dynamics 365 – Problems debugging fields on a form

“ If debugging is the process of removing software bugs, then programming must be the process of putting them in. ” – Edsger Dijkstra

Dynamics 365 is a place where only dirty entities and fields are saved! The clean fields are ignored #HoskCodeWisdom

  • Junior developer – assumes how things work
  • Good developer – finds out through trial and error
  • Great developer – does not assume and methodically confirms

Dynamics 365 can frustrate developers (The Frustrations of a CRM Developer), developers are provoked by the idiosyncratics, limitations and bonkersness of Dynamics 365 as Microsoft works on new ways to annoy developers 🙂

Bugs and problems areopportunities to gain a deeper knowledge of the workings of Dynamics 365.

New developers get caught out such as in the CRM 2011 (good old) when SetSubmitMode was a rite of passage for Dynamics CRM developers – CRM 2011/2013 – What does setSubmitMode do? and how does it work?

Unless you made the field dirty and change SubmitMode the field was not sent to the database to be saved

Try, Try and try again

On creation of an appointment the start and end times should be editable, on a form update those fields should be readonly.

Examples of using the SetDisabled(true) were found in the code, copied and adapted for the start and end times on the appointment entity.

He kept debugging and being puzzled because the start and end times were not changing, but why not?

Insanity: doing the same thing over and over again and expecting different results.  Albert Einstein

Developer Insanity: Testing the same code over and over and expecting intermittent result #HoskCodeWisdom

Hosk developer debugging beliefs

  • Investigate bugs with an empty mind
  • Microsoft 365 is full of quirks which make sharing knowledge between team members important
  • Bugs are not a sign of a bad developer, they are a sign of a developer developing #HoskCodeWisdom
  • Always help your fellow developers, big projects need a strong team.  Never leave a developer stranded
  • Don’t suffer in silence if you are not making progress, get help and get direction #HoskWisdom

SetDisabled = true

The way to make a read-only field editable is to use the Dynamics 365 JavaScript Xrm, get the control and use the setDisabled(false)

Xrm.Page.ui.controls.get(“your field name”).setDisabled (true); //Field readonly you can’t write any thing on field

if you change true as false;

Xrm.Page.ui.controls.get(“your field name”).setDisabled (false); //Anyone can put value on this field

I looked at the code, it looked fine, we checked a few things

  • Is there any other code changing the field back to read only –> No
  • Checked the line worked in the debugging console –> Yes
  • Was there a JavaScript error –> No
  • Debug the code, does it run the line of code which enables the field –> Yes

Appointment entity

In this example we used the appointment entity, which is an odd entity.  It‘s not possible to add new forms for the appointment entity Dynamics 365 – You can’t add new forms to the appointment entity There is code running on the appointment entity which a CRM developer has no control over, cannot see and cannot edit.

When you book appointment it sets the user who booked the appointment as the organizer of the appointment.  This is fine for Outlook but not what I wanted to happen in Dynamics 365.

Adding hidden custom code which developers can’t disable is frustrating as much as it is undocumented, believe Microsoft should write customizations in the same way standard Dynamics 365 developers do. This would allow us to see, modify, disable or extend the default behavior.

Stop, think

When you rule out the obvious, it’s time to check the stupid – #HoskWisdom

Appointment entities don’t allow you to add new forms (or change the status/status reason of the appointment) because we couldn’t add new forms, we had JavaScript which when the regarding field was set to a specific custom entity we disabled the default section and showed a new section with custom fields on.

Usually a developer would create another form but we couldn’t because it was the appointment entity

This resulted in the same fields being on the form twice, the start and end times.  So the code was working, except it was making the fields on the hidden section and the first fields on the form.

To resolve the problem go to the section (in code) and then retrieve the field you want and then make it make it editable.

Hosk values with bug fixing

  • Developers who fix a problem which doesn’t keep popping back because it‘s not properly fixed
  • Developers who use a bug as an opportunity to learn how Dynamics 365 works
  • Developers should try to resolve the problem first before asking for help
  • Don’t spend too long being puzzled by a bug before asking for help, Dynamics 365 has odd quirks and limitations which can take hours to resolve.  Get direction from a colleague after 1 hour of frustration
  • Developers should not assume, they must clarify (I wasted hours looking in the wrong place because I didn’t check my assumptions)

On a separate note but relatedish – Developers using JavaScript onload should be careful when setting and changing values because it can frustrate user by asking them to save a form when they haven’t change any values When to automatically change fields using Javascript 

picture from here

Don’t let a marshmallow crush your project

 

“The only real mistake is the one from which we learn nothing.” – Henry Ford

When people can think of the team before themselves, the team can achieve great things #HoskWisdom

Code not in production has no value, you don’t know if it will work, get it live in the shortest time possible.

Beliefs

  1.  Get your code finished into production and the customer starts to get value
  2. The longer code isn’t in production, the larger the risk it won’t work or be what the users need
  3. Test your design with a prototype is always better than having a design on paper
  4. Politics and positioning for power can slow and divert projects
  5. Adults fear failure/mistakes more than children and because of it they make bigger mistakes

Build a tower

A popular team building exercise sets teams of four people to build the tallest tower possible using 20 sticks of spaghetti, sticky tape, string and a marshmallow which has to sit on top.

Ted talk – Build a tower, building a team

here are some crazy designs

I attended a similar exercise using spaghetti and jelly babies.  It was a fun(ish) but lacked a point but getting to know your team is important, so it all helps.

Common problems

Many individuals waste time jockeying for position, trying to assert their authority at the expense of doing the task well.  The video states children don’t waste time doing this, they focus on the task not people and position.

Many of the people doing the exercise will create the spaghetti tower and leave putting the marshmallow on the top at the end, with one minute to go.  This leads to a either successfully putting the marshmallow on the top or the marshmallow destroying the towr because it‘s too heavy.

Most teams leave creating prototypes and testing their designs until the last minute, with no time to adjust.

Mr Stay Puft visits your project

Dr Ray Stantz: [after Ray thinks of the Stay Puft Marshmallow Man and it appears, stomping through New York City] I tried to think of the most harmless thing. Something I loved from my childhood. Something that could never, ever possibly destroy us. Mr. Stay Puft.

Dr. Peter Venkman: Nice thinking, Ray.

 

Leaving the marshmallow until the end is the classic waterfall approach to projects, the marshmallow in the project can be

  • Show the customer and finding out it‘s not what they want
  • The functionality does not work
  • The functionality doesn’t work the way the users/business needs
  • performance problems
  • The integrations don’t work

Waterfall projects leave the risk (the marshmallow) until the end and leaving no time to change or adapt.

You can tell Mr Stay Puft will visit your project when the requirements and functionality are not linked to business goals and there is a lack of business input.  IT projects are a collaboration between the business and developers.

If it smells like agile

The most successful teams created prototypes and put the marshmallow on their tower at the earliest moment.  Creating working examples is key, you can try a different design if the marshmallow squashes your design and you can adapt working designs.

Agile aims to get functionality finished and into production as soon as possible, allowing user to see and use it as soon as possible.  This stops the two sides drifting apart because at the end of every sprint they are pulled together to review progress and get feedback.

Agile is great when done well and the customer engages in the agile process, I have discussed Scrum in a blog post before

There are many projects which are Agile in name but chaos in reality #HoskWisdom 

Many businesses cannot fight the desire to plan out the project and costs, despite everyone knowing long term planning is never accurate.  It helps to remember another name for estimate is guess and adjust your confidence levels accordingly.

On your next project, get code into production as soon as possible to ensure you are creating what’s needed, what’s wanted and what works.

pictures from here, here

 

Hosk’s Top Dynamics 365 Articles of the week – 16th June

Quotes

But man is not made for defeat. A man can be destroyed but not defeated. Ernest Hemingway

#HoskWisdom

Want more #HoskWisdom then follow #HoskWisdom, #HoskCodeWisdom or follow @BenHosk 

  • The pressure to make things complex will be great but you must keep it as simple as possible #HoskWisdom
  • Don’t waste words, make every one count #HoskWisdom
  • If you can deliver the same message with fewer words then do so #HoskWisdom
  • if you tried your hardest you have nothing to regret #HoskWisdom
  • Constantly talking about doing something is a barrier to doing something #HoskWisdom
  • Speak less, listen more and think often #HoskWisdom
  • If something has no value, stop measuring it #HoskWisdom
  • Contributing to a successful team is better than achieving personal goals #HoskWisdom
  • People admire Dad dancing because it is a state of mind only achieved by those who are not constrained by popular opinion #HoskWisdom
  • Leaders don’t try to win the race they try to get everyone to finish #HoskWisdom
  • Don’t over think and under act #HoskWisdom
  • Thinking should not stop action #HoskWisdom
  • Respect silence, its thinking time #HoskWisdom
  • Don’t waste your energy fighting the inevitable, instead choose to be prepared #HoskWisdom
  • Bosses should tell employees where they can do better but most don’t #HoskWisdom
  • I like to start the day with a steaming hot cup of Microsoft Dynamics 365 #HoskWisdom
  • Win when you can, lose if you must but always enjoy it #HoskWisdom
  • There are no shortcuts in delivering successful projects #HoskWisdom
  • Be relentless about improving #HoskWisdom
  • You won’t win if you are afraid of losing #HoskWisdom
  • Rejection makes you serious about a goal or helps you decide it’s not important #HoskWisdom
  • When a pupil isn’t doing well the reason is often due to bad teaching #HoskWisdom
  • You cannot go back to what you were, you can only move forward to what you will be #HoskWisdom
  • When conflict becomes personal, it becomes a problem #HoskWisdom
  • For the people who achieve, tomorrow is too late #HoskWisdom
  • If you lose because of a lack of preparation then you beat yourself #HoskWisdom
  • No one will follow a leader who isn’t good at his job #HoskWisdom
  • When you let sleeping dogs lie, be prepared to be woken by those dogs in the future #HoskWisdom

Articles of the week

awesome-1

Generic framework to delete all child records when a parent record is deleted in Dynamics 365 using Microsoft Flows

Best of the rest

Restarting Record Creation and Update Rules in Dynamics 365

Dynamics 365 UK data centres

 Insights from Extreme 365

Simple, No fuss, Dynamics 365 Deployment Task Runner

How to register an early bound library within Microsoft Dynamics CRM Online Sandbox Isolation Mode Part 1

word document templates for complex data retrieval

you can optimize queries in Dynamics 365 online! it doesn’t say what it does but it’s probably magic

Calling Azure Functions (GenericWebHook-Csharp) from CRM

Tip #863: Learn TypeScript

Facial Recognition using Dynamics 365, PowerApps and FaceAPI

Best of the rest

Recurring Jobs Strategies for Dynamics CRM/365

The New Social Selling Assistant in Dynamics 365

Dynamics 365 Partner Community: Using PowerApps and Microsoft Flow with Dynamics 365

CafeX, Live Assist – My Initial Install (With USD)

A BETTER WAY TO USE CONNECTIONS

Record Specific Power BI Reports in Dynamics 365 (only one click away)

Managing Dynamics 365 Online Encryption Key

Programming/Scrum

Shutting down CodePlex

popular dev articles this week

Here’s What You Can Learn In 10 Minutes That Will Be Useful For The Rest Of Your Programming Career

Writing My First Compiler

Continuous everything in DevOps…what is the difference between CI, CD, CD…?

The Agile Mindset 

Tips To Be a Successful Scrum Master

awesome information for Scrum masters

great article on why you should do code reviews

Why is the ‘if’ statement considered evil?

Other

I woke up at 3 a.m. to spend 12 hours learning what it takes to be a leader from former Navy SEALs

How I Became More Comfortable With Public Speaking

9 Books Which Made Me an Adult (And 1 You Should Read Anyway)

16 Memorable Books I read in 2016

Flow Doesn’t Lead to Mastery

Why Are Maker Schedules So Rare?

Darwin was a slacker

What Your Moonshot Can Learn from the Apollo Program

How to get employees to work faster

Man’s tweet about pie charts being useless causes hilarious chaos

Star Wars

Tina Fey improve tips

The Hosk – currently reading

Hosk’s CRM Developer Articles

A collection of my favorite CRM Developer articles I have written

CRM 2016 – Tips on passing the MB2-712 customization and config exam

All the CRM 2016 content to help you pass the exam

picture from here

Dynamics 365 – How to install the Microsoft Dynamics 365 Developer Toolkit

wizard-hosk-install

I blogged about uninstalling the Microsoft Dynamics 365 Developer Toolkit and released I hadn’t explained how to install the Microsoft Dynamics 365 Developer Toolkit

If you want to learn what the developer toolkit is and why it’s useful, read this page

You can find manually download the toolkit here

Microsoft Dynamics 365 Developer Toolkit marketplace

The quickest way to install the Microsoft Dynamics 365 Developer Toolkit is straight from Visual Studio.

Go to Tools –> Extensions and updates

search for Microsoft Dynamics 365 Developer toolkit

install-developer-toolkit

Install

install-developer-toolkit-1

You will then be able to create Dynamics 365 projects and connect to Dynamics 365 projects.

I would recommend getting the latest version of the Dynamics 365 SDK and regularly update the Developer toolkit because it has a few bugs but they are fixing them regularly

 

 

Dynamics 365 – Alternate keys can stop duplicates

Without reflection, we go blindly on our way, creating more unintended consequences, and failing to achieve anything useful. Margaret J. Wheatley

Alternative keys allow you to lookup records without having the guid of the record, they give a method to stop users adding duplicates, speed up Dynamics 365 searching and are useful for integrating Dynamics 365 with external services/systems.

Key facts

  • Alternate keys can stop duplicates
  • Alternate keys can increase record lookup speed
  • Alternative keys allow you to lookup records without a guid but with information which makes an alternate key.  E.g. lookup a person using surname and email.
  • Work well with upsert, allowing you to find a record and either update or create
  • Can sometimes cause problems when trying to remove them solutions
  • Added in Dynamics CRM 2016 and available in Dynamics 365 online and on premise

What is an alternate key?

An alternate key can be added to an entity and can be made up of one or more fields on the entity.  Alternate keys use database indexes, this has the benefit of making records unique by stopping duplicates and increasing performance when retrieving records with an alternate key.

Alternate key facts

  • Each entity can have 5 alternate keys
  • You can only use strings, decimals and integers (whole number) to create an alternate key
  • There is a maximum key size to be aware of
  • After creating an alternate key, an async job will create the index and the status will be pending, In Progress, Active and failed.  If you have a lot of records this could take a long time.
  • You can retrieve an alternate key using RetrieveEntityKeyRequest, you delete an alternate key using DeleteEntityKeyRequest.

To learn more about alternate key read the posts

Stopping Duplicates

Alternate keys is they give a way to stop users adding duplicate records.  When you add an alternate key and a user tries to add a duplicate, Dynamics 365 will stop the user from adding the record and show the warning below.

 

 

 

 

 

 

This is better than out of the box duplicate stopping functionality which only warns the user but lets them add a duplicate.  The alternative is to stop duplicates via a plugin, which takes more effort and has a maintenance overhead.

Summary

It’s difficult to remove alternate keys from managed solutions, I have had problems where Dynamics 365 didn’t want to remove the alternate key.

The limitation of using numbers and strings can leave you frustrated when you want to use a date field.  You can work aaround this by converting a date field to a string but it‘s messy.

picture from here

How Machine learning will change Dynamics 365

Machine learning is working smarter, using data to interact with customers in different ways.  Machine learning analyses your data to help your business to respond using experience and recommendations.

I was reading my colleagues post on Machine learning CRM 2016 Prices + Machine Learning = Profits & Retention and this article – why salespeople need to develop machine intelligence

Companies are focused on capturing new business they often forget to look at existing customers, how they can improve the relationship and improve selling.

You already have a great relationship with an existing customer so a lot of the hard work is done, Machine learning rise prices or offer other products .

When ever I think of Machine learning I think of Amazon’s recommendations, you brought this book

An example of Machine learning is Amazon’s recommendations, you I brought 

it recommended
The recommendation was great, I appreciate they are trying to sell me a product but I often the suggested books are usually tempting (I can’t buy any more books I have a whole book shelf of books to read)

What is Machine learning?

I hear the term, I have read it’s been added to Dynamics 365 but what is Machine learning
Wikipedia – Machine Learning
Machine learning is the subfield of computer science that gives computers the ability to learn without being explicitly programmed.  Evolved from the study of pattern recognition and computational learning theory in artificial intelligence, machine learning explores the study and construction of algorithms that can learn from and make predictions on data – such algorithms overcome following strictly static program instructions by making data driven predictions or decisions, through building a model from sample inputs. Machine learning is employed in a range of computing tasks where designing and programming explicit algorithms is infeasible; example applications include spam filtering, detection of network intruders or malicious insiders working towards a data breach, optical character recognition (OCR), search engines and computer vision.

The description is why it can be difficult for people to understand what machine learning is and how it will be used in the future.

This blog post describes machine learning – machine learning theory an introductory primer

There are two main types of machine learning

  • Supervised machine learning: The program is “trained” on a pre-defined set of “training examples”, which then facilitate its ability to reach an accurate conclusion when given new data.
  • Unsupervised machine learning: The program is given a bunch of data and must find patterns and relationships therein.

These blogs show examples of Machine learning

Examples of machine learning

  • Sentiment on tweets
  • Adds on Amazon/Facebook
  • Self driving cars
  • Imaging tagging in Facebook
  • Text analysis in emails

The examples help to understand what machine learning does, it can crunch large amounts of data looking for patterns you have trained it identify.

Machine Learning and Microsoft Dynamics CRM

Here are some examples of Machine learning and Dynamics 365

How will machine learning change CRM

The most effective environment for machine learning is to analyse activities which happen thousands of time.

Machine learning can analyse the data and learn, the more data the better.  The rules apply for Machine learning

 

  • Good data in, good data out
  • with machine learning think
  • lots of good data in, useful analyse out.

Amazon recommendations learns from the buying patterns of thousands/millions of customers, the crunching of lots of data enables Amazon to make useful recommendations and not annoy customers with annoying recommendations.

benefits of Machine learning

Recurring activities and data do we get in Dynamics 365

Where will the opportunities for machine learning occur in Dynamics 365

Product recommendations – Lead generation

Customers who buy this product are usually interested in this other product.

One powerful selling points of Microsoft Dynamics 365is offering the potential for customers to use their existing data to increase sales and increase selling effectiveness. If a company could focus on quality leads, focusing on selling products to customers who are interested in those products, it can sell more.

This would allow sales teams to time effectively, selling to existing customers.

Machine learning could automate suggests on what customers would want specific products.  Machine learning gives this knowledge to all the sales people not just experienced sale people

Customer service sentiment

Social engagement has machine learning in its core functionality.  You can train the social engagement to recognise sentiment in tweets and blog posts.  You can create cases based on tweets with negative sentimen

Lead Scoring + Marketing

Machine learning would seem to be a great choice to help evaluate success marketing campaigns, marketing distributions

Segmentation

Machine learning can do customer segmentation, sorting and organising customers.  This could lead to targeted interaction with customers, working smarter not harder.

This article suggests three areas around products

new customers – machine learning can help you find the right product for the right customer. Machine learning to analysis who you sell to and make recommendations on the target audience.

Retain customers – Customer service

Respond quicker to tweets and emails by using Machine learning to identify problems with sentiment in communication (SMS, tweets, Facebook, email)

Sell to existing customers

Machine learning can help with Cross sell, upsell and targeting new products to existing customers.  Think of Amazon recommending items based on your purchase history.  This could be used in Microsoft Dynamics 365.

Machine learning plus automation = Awesome

It’s a great moment when you are selling/demoing Microsoft Dynamics CRM to a potential client and you explain how workflows work.
Workflows enable business to automate some of the manual steps in a process, giving the business the double benefit of
  • Not forgetting to do part of the process
  • users not needed to do part of the process

The potential of workflows to save time and add value is obvious, the difficult part is mapping out the processes.  Processes having three paths

Don’t just test the happy path

Workflows need inputs to trigger them, this can  change of status, an email coming in.

Machine learning is an informed assistant, it analyses repetitive actions and uncover patterns and successful strategies.  This learning is what  humans called experience e.g. learning what not to do and what to do.  We can tell machine what’s good, what’s not and then it goes through the data and applies the criteria we have given it.

This could simulate an experienced person going through the data and advising what they think we should do.  The benefit with machine learning is it can sift through data and advise what records to focus on.

The future of Dynamics 365 and machine learning

Machine learning in Dynamics 365 will need developers to understand what machine learning is and how it works.  Most people have heard of machine learning but few people understand how to use it with Dynamics 365 or have experience of implementing it.

Once the Microsoft Dynamics 365 industry gets used to machine learning, gets practical and theoretical knowledge, Solution architects will become adept at seeing where machine learning can be used.

an opportunity for businesses to change and adapt their processes to use machine learning.

It will not be a smooth a ride, taking time for Microsoft Dynamics 365 professionals to understand machine learning and sell it to customers.  Selling the business benefits of machine learning is difficult because customers can’t see what they will be getting.  It‘s not a dashboard, a portal or something visible.

Marchine learning is a long term investment with potentially dramatic benefits

picture from here

Hosk’s Top Dynamics 365 Articles of the week – 31st March

Quotes

You can’t win together if you don’t work together – Nick Saban

Development experience and skills are created through time spent developing #HoskCodeWisdom
You have to be relentless in the pursuit of your goal, be prepared of to work through adversity and hard times #HoskWisdom

Articles of the week

awesome-1

Article of the week

Best of the rest

Other

Previous Hosk Top Articles

Hosk’s Top Dynamics 365 Articles of the week – 22nd February

The Hosk – currently reading

The Hosk – just finished reading

Hosk’s CRM Developer Articles

A collection of my favourite CRM Developer articles I have written

CRM 2016 – Tips on passing the MB2-712 customization and config exam

All the CRM 2016 content to help you pass the exam

picture from here