Title Page
Microsoft Dynamics 365 Extensions Cookbook
More than 80 extension recipes to get the most out of Microsoft
Dynamics CRM
Rami Mounla
BIRMINGHAM - MUMBAI
Copyright
Microsoft Dynamics 365 Extensions Cookbook
Copyright © 2017 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of
the information presented. However, the information contained in this book is sold
without warranty, either express or implied. Neither the author, nor Packt Publishing,
and its dealers and distributors will be held liable for any damages caused or alleged
to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
First published: June 2017
Production reference: 1020617
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78646-417-0
www.packtpub.com
Credits
Author
Copy Editor
Rami Mounla
Zainab Bootwala
Reviewer
Project Coordinator
Nicolae Tarla
Prajakta Naik
Commissioning Editor
Proofreader
Aaron Lazar
Safis Editing
Acquisition Editor
Indexer
Shaon Basu
Tejal Daruwale Soni
Content Development Editor
Graphics
Lawrence Veigas
Abhinash Sahu
Technical Editors
Production Coordinator
Pranali Badge
Melwyn Dsa
Dhiraj Chandanshive
Foreword
We all need recipes! Some we learn from books, some we ask for, and some we
accidentally stumble across. Software recipes are no different to culinary ones, in
that, they enable us to cook up great things with ease and repeatability. Rami's
Microsoft Dynamics 365 Extensions Cookbook is no exception!
I have followed Rami's technical community contributions and blog for many years,
and so I was really pleased to learn of his well-deserved Microsoft MVP award
back in 2015. When we first met, I was immediately struck by his infectious
enthusiasm for Microsoft Dynamics CRM and related technologies, along with his
commitment to continuously improving the way we deliver solutions on this unique
platform.
Naturally, we both share the same passion for the benefits of using Microsoft
Dynamics 365 online, along with all of its value-added services. Rami's recent major
public sector implementation of Microsoft Dynamics 365 Online is the first of its
kind in New Zealand, which clearly shows that the trust in Microsoft's ability to
deliver a world class software-as-a-service is ever-growing. This is further evident
as an increasing number of organizations are choosing Microsoft Dynamics 365
Online in conjunction with Microsoft Office 365 and Microsoft Azure to build their
next generation of business solutions. Microsoft’s continued and significant
investment in areas such as Machine Learning, Big Data, and IoT (Internet of things)
allows them to constantly reinvent the platform to increase the value and productivity
that they can bring to their customers.
For me, Microsoft's platform-first approach has always been their market
differentiator. Now that the Dynamics product team is being steered by Scott Guthrie
(Microsoft executive vice president, Microsoft Cloud and Enterprise), we are
increasingly seeing Microsoft Azure services being utilized to bring new features and
to rapidly evolve the platform into areas that present exciting new "Digital
Transformation" opportunities. For instance, companies that historically would have
been purely focused on monitoring of their product sensors, now, with an Azure IoT
Hub, can now take advantage of Microsoft Dynamics 365 to provide predictive
maintenance to their customers through Microsoft Azure Machine Learning.
Furthermore, sales organizations that previously relied on their sales staff to spend
valuable time and effort on maintaining account plans can now use Customer Insights
and LinkedIn Sales Navigator to increase productivity and drive business growth.
These kinds of projects no longer need large teams of data scientists and machine
learning researchers, but are available to us mere mortals, enabling our users and
customers to do business in a way that was previously cost prohibitive and
inaccessible to most.
In this book, Rami offers clear and concise solutions so that you may benefit from his
many years' experience with the Microsoft Dynamics CRM and Microsoft Dynamics
365 platform, and get the most out of its powerful features and extensibility points.
The recipes are logically organized into categories to make it easy to understand their
applicability, each with not only clear and practical steps on how to implement them,
but also crucial technical details of how and why they will work. We are certainly
lucky to be part of such an active technical community with many great contributors,
so I particularly like that for each technique Rami shows you, he also offers you
additional resources to grow your understanding and develop your skills further.
It is true that we will rarely encounter an implementation challenge that has not
already been solved by someone before us. I am a firm believer in learning from the
experience of those people so that we may stand on the shoulders of giants! By
following Rami's recipes in this book, no matter whether you are using Microsoft
Dynamics 365 On-Premises or Dynamics 365 Online, if you are implementing largescale enterprise solutions or smaller ones, the consistency and quality that the
contents of this book will bring to your implementation will not only give you more
time to focus on delivering business value, but also make your solutions more
supportable and upgradable in the future.
As we see Microsoft continuing to develop their exciting platform, I am confident
that by reading this book, you will learn many valuable practical skills from Rami
that will accelerate your career into the next chapter of Microsoft Dynamics 365's
evolution.
Scott Durow
Solution Architect, Develop 1 Ltd.
Microsoft Business Solutions MVP
Author of the Ribbon Workbench and SparkleXrm
About the Author
Rami Mounla is a Solution Architect with over 15 years of experience in IT. He was
introduced to Dynamics CRM 3.0 when it first came out and has built a career around
the product since then. Based in Wellington, New Zealand, his focus is on enterprisescale Dynamics CRM solutions targeted at the public sector and large multinational
corporations. Throughout his career, he has worked on some of the largest CRM
implementations in New Zealand, both on-premise and in the cloud.
Rami is active in the Dynamics community, a leader of the Wellington Dynamics User
Group, a frequent speaker at Microsoft Ignite New Zealand, and a supporter of open
source Dynamics 365 extensions. His contributions over the last few years gained
him the Microsoft Business Solutions MVP status in 2015, a title that reflects his
ambitions.
After being frustrated with frequently reviewing poor-quality CRM implementations,
Rami decided to write about best practices and promote quality CRM
implementations. The topics and ideas inspired this book on extending Dynamics
365.
I would like to dedicate this book to my patient wife, Amanda, who supported me
throughout the journey, despite having a 2-year-old and a newborn to look after.
You rock!
To my two boys, Alexander and Riaan, who make every day worth it.
I would also like to thank my Mum and Pup without whom none of this would be
possible.
A special mention to my brother Edd who pushed me really hard over the years to
strive for excellence and encouraged me to write this book.
Thank you Aung Khaing for answering the tough questions and for the long
conversations when I was tossing between ideas. Thank you Abhay Mishra and
Mingyao Lin for the good times and for the coffees when I needed them the most.
Nicolae Tarla, thank you for all the constructive feedback and for sharing your
years of experience in Dynamics and in book writing.
Scott Durow and the MVP family, thank you for your enthusiasm and for your
ever-so-inspiring community work that encouraged me to become an MVP and to
keep contributing.
Last but not least, thank you to the team at Packt for turning my dream into reality.
About the Reviewer
Nicolae Tarla is a Microsoft Dynamics 365 Consultant specialized in solution
architecture and technical presales. He has worked on various mid-to-enterpriselevel Dynamics CRM, Office 365, and SharePoint implementations for both the
private and public sectors. He has been delivering Microsoft Dynamics CRM
solutions since version 3.0 of the product.
Nicolae has participated as a technical reviewer and author on several books,
presented at several events and conferences, and is blogging at .
He was awarded the Business Solutions MVP title for his contributions to the
Dynamics CRM Community.
I would like to thank the author for offering me the opportunity to review this
book. It was a great experience assisting on this project.
In addition, a big thanks goes to the Dynamics 365 Community for appreciating
these efforts, and driving us to give back and share our knowledge.
www.PacktPub.com
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF
and ePub files available? You can upgrade to the eBook version
at www.PacktPub.comand as a print book customer, you are entitled to a discount on the
eBook copy. Get in touch with us at for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up
for a range of free newsletters and receive exclusive discounts and offers on Packt
books and eBooks.
/>
Get the most in-demand software skills with Mapt. Mapt gives you full access to all
Packt books and video courses, as well as industry-leading tools to help you plan
your personal development and advance your career.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Customer Feedback
Thanks for purchasing this Packt book. At Packt, quality is at the heart of our
editorial process. To help us improve, please leave us an honest review on this
book's Amazon page at />If you'd like to join our team of regular reviewers, you can e-mail us at
We award our regular reviewers with free eBooks and
videos in exchange for their valuable feedback. Help us be relentless in improving
our products!
Table of Contents
www.PacktPub.com
Preface
What this book covers
What you need for this book
Who this book is for
Sections
Getting ready
How to do it…
How it works…
There's more…
See also
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1.
No Code Extensions
Introduction
Modeling denormalized entities
Getting ready
How to do it
How it works...
See also
Modeling normalized entities with a common parent
Getting ready
How to do it
How it works...
See also
Modeling independent normalized entities
Getting ready
How to do it
How it works...
See also
Using a Business Rule to show and hide attributes
Getting ready
How to do it
How it works
There's more...
Building a configurable e-mail notification workflow
Getting ready
How to do it
How it works...
There's more
See also
Building your first action
Getting ready
How to do it
How it works...
See also
Setting up the rollup fields
Getting ready
How to do it
How it works...
Frequency
Programmatic Rollup Field execution
There's more...
Different types of aggregation
Indirectly related activities
See also
Setting up calculated fields
Getting ready
How to do it
How it works
There's more...
See also
Duplicate detection using alternate keys
Getting ready
How to do it
How it works
2.
Client-Side Extensions
Introduction
Creating your first JavaScript function
Getting ready
Visual Studio and Developer Tool Kit
XrmToolBox's Web Resources Manager
How to do it...
How it works...
There's more...
See also
Wiring your event programmatically
Getting ready
How to do it...