Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Microsoft Dynamics 365 Extensions Cookbook

You're reading from   Microsoft Dynamics 365 Extensions Cookbook Add functionality to existing model elements, source code and finally package and deploy using DevOps

Arrow left icon
Product type Paperback
Published in Jun 2017
Publisher Packt
ISBN-13 9781786464170
Length 462 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Rami Mounla Rami Mounla
Author Profile Icon Rami Mounla
Rami Mounla
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. No Code Extensions FREE CHAPTER 2. Client-Side Extensions 3. SDK Enterprise Capabilities 4. Server-Side Extensions 5. External Integration 6. Enhancing Your Code 7. Security 8. DevOps 9. Dynamics 365 Extensions 10. Architectural Views 11. Dynamics 365

Modeling denormalized entities

Typically, account and contact entities are the most commonly used entities in a Dynamics CRM implementation. In large implementations, those entities are usually also reused for multiple purposes. To illustrate the modeling pattern, this recipe will leverage the college solution described in the introduction. We shall concentrate on creating contacts that can either be individuals or students. Each type of contact requires a different set of attributes.

The easiest way of modeling a multi-purpose entity is to add all the required attributes for the different types to the same entity.

Getting ready

In order to configure the schema, you will need to have access to a Dynamics 365 instance along with a System Customizer or higher security role . As a best practice, it is always recommended that you implement your configuration within a solution. For the purpose of this book, it is expected that you already have a solution created called Packt with a publisher prefix of packt_.

How to do it

  1. Navigate to Settings | Solutions | Packt.
  2. Click on Add Existing | Entity and select Contact, as shown in the following screenshot:
  1. Select the necessary assets that support your configuration and add them to your solution, or, for simplicity, select Add All Assets and click on Finish:
  1. Click on No, do not include required components.
  2. Navigate to Entities | Contacts | Fields.
  3. Click on New, and create an attribute called Student Id of type Single Line of Text, and click on Save and New.
  4. Create an Option Set attribute called Contact Type that contains two values; Student and Other. Then click on Save and Close.
  5. Back in the solution, navigate to Entities | Contact | Forms and click on New | Main Form as per this screenshot:
  1. In the newly created form, add the two newly created fields to your form by dragging and dropping the entities from the right-hand window onto the form.
  2. Click on the Publish All Customizations button for your solution.

How it works...

Just like database modeling, entities can be normalized or denormalized. Normalizing a structure is the action of separating it into several related tables to reduce redundant data or empty fields. Denormalizing a structure is the opposite: we merge two or more tables together to simplify the structure and improve query performance, whilst adding redundant or empty fields. In this recipe, the entity was denormalized to allow different types of contacts to be surfaced through the same contact entity.

In step 1 to step 4, we added the existing contact entity to the Packt solution. Notice that in step 3, we had the option to either add the necessary assets or add all assets. For this recipe's simplicity, we added all assets. With the recent granular solution enhancements, we can simply add what is required.

It is a best practice to minimize the number of unnecessary attributes and relationships in a solution to avoid conflicts and dependencies.

In step 5 to step 7, we created the attributes, and in step 8 and step 9, we added the attributes to a new contact form. In step 10, we published the configuration we implemented.

To avoid multi-solution dependencies and scenarios where a form is overwritten with an updated version from another solution, best practice dictates that you create a new form for your solution and mark it as default. Unnecessary forms can always be hidden by using Apps as described in Chapter 9, Dynamics 365 Extensions.

Looking at the design of the updated entity, we have now configured the contact entity to fulfill more than one purpose: it is a generic contact as well as a student one.

A simplifiedEntity Relationship (ER) diagram is depicted in the following screenshot:

The advantages of a denormalized model are:

  • Views will appear in the same combined list
  • A quick and advanced find will include both types and display the results in the same list
  • Positive form user experience, driven by the form configuration

The disadvantages of a denormalized model are:

  • Security roles cannot easily be made specific to types
  • Configuration/customization is required to show/hide irrelevant attributes or to mark them as mandatory or optional
  • Records will contain blank fields when not applicable

See also

  • Modeling normalized entities with a common parent
  • Modeling independent normalized entities
  • Using Business Rule to show and hide attributes
  • The Dynamics 365 applications recipe of Chapter 9, Dynamics 365 Extensions
You have been reading a chapter from
Microsoft Dynamics 365 Extensions Cookbook
Published in: Jun 2017
Publisher: Packt
ISBN-13: 9781786464170
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime