Part 28 - Entity and EntityReference Using Plugin in Dynamic 365 CRM


===> Lets understand Entity and EntityReference in simple way using below example.


1. Think of a Classroom:

  • There are students.
  • Each student has a student ID.
  • The teacher wants to give marks to students.

In This Example:

  • Student → Is like a Record (Entity) in CRM.
  • Student ID → Is like an EntityReference in CRM.


2. Entity = Actual Student Details

===> A student has:

  • Name: Vamshi
  • Age: 15
  • Class: 10th Grade

===> Entity stores all the actual student information.


3. EntityReference = Just the Student ID

===> The teacher doesn’t carry all student details.

===> Instead, they use the Student ID to find the record.

Student ID: 12345

===> EntityReference is like saying: "This Student ID belongs to John."

4. Why Do We Use Entity and EntityReference

===> Entity is used when we need all the student details.

Example: The teacher wants to see a student’s name, age, and marks

===> EntityReference is used when we just need to refer to a student using their ID.

Example: The teacher writes marks using the Student ID without seeing all the details.


5. Lets see How It Works in CRM Plugins:

Scenario:

===> A plugin runs when a new Order is created in CRM.

===> The plugin automatically creates an Invoice.

1. Entity:

  • The plugin captures the actual Order data (like Order Number, Total Amount).

2. EntityReference:

  • Instead of capturing all customer details, it just uses a Customer ID using EntityReference.


Order Created in CRM

  • Order Number: 101
  • Total Amount: ₹5000
  • Customer: (EntityReference: Customer ID 123)

Invoice Created in CRM

  • Invoice Number: INV-001
  • Linked to Customer using Customer ID 123


Here’s how the plugin works using both Entity and EntityReference:

Article content

Explanation:

  • Capture Order Details:

===> The plugin reads all the Order data using Entity.

  • Get Customer Using EntityReference:

===> It doesn’t load all the customer details.

===> It just uses the Customer ID using EntityReference.

  • Create an Invoice:

===> Using both the Order data and the Customer ID, the plugin creates an Invoice in CRM.


6. When to Use EntityReference:

.===> When Linking Records Using Relationships

===> When You Only Need a Reference Without Retrieving the Full Record

===> When Performing Updates on Lookup Fields

===> When Executing Requests That Require References


7. When NOT to Use EntityReference

  • When you need detailed information from a record (e.g., all field values) — in this case, use Retrieve() or RetrieveMultiple().
  • When performing complex queries using FetchXML or QueryExpression.
  • When creating a new record — you would use an Entity instead.


Conclusion:

Article content


To view or add a comment, sign in

More articles by Vamshi Krishna Chadalavada

  • Part 3 - Microsoft Power Platform Environment

    ===> Before we start building Power Pages, we must understand Power Platform Environment. 1.

    1 Comment
  • Part 2 - Power Pages Architecture

    ===> When we say Power Pages Architecture, we are talking about: How a Power Pages website works behind the scenes when…

  • Part 1: Introduction to Power Pages

    First lets understand what problem does Power Pages Solve ? Lets take real time example: Imagine you work in a company…

  • Script Finder in XrmToolBox:

    Introduction ===> When working with complex Dynamics 365 CRM implementations, JavaScript customizations are widespread…

  • Microsoft Power Platform Solution Deployment Pipeline

    Introduction Managing Application lifecycle in the Microsoft Power Platform has always been critical to maintaining…

  • Understanding & Implementing Custom API in Dynamics 365 CRM

    What is a Custom API? ===> A Custom API in Dynamics 365 CRM is a way to define your own server-side business logic as a…

    12 Comments
  • Implementing Custom Actions in Dynamics 365 CRM

    Scenario: Loan Application Approval Process (Banking CRM) Business Requirement: When a loan application is submitted…

    5 Comments
  • Actions in Dynamics 365 CRM

    1. What is Action: In Dynamics 365 CRM, an Action is a custom business operation that you define once and can run…

    2 Comments
  • Part 2 - Microsoft 2025 Release Wave1

    ServiceNow → Dataverse Integration using Power Automate Objective: ===> We want to create a Power Automate flow that:…

  • Part 1 - Microsoft 2025 Wave Release1 - Sales Module

    ===> Microsoft added Smart AI tools (called agents) that help your sales team: Understand leads better. Pick the best…

Others also viewed

Explore content categories