Microsoft Dynamics 365 CRM - Fields(Columns)
Part 3 - Fields(Columns) in PowerApps - Model Driven App
---> In Power Apps Model-driven apps, fields (also known as columns) are used to store data for each record in an entity.
---> There are several types of fields, each designed to handle different types of data.
Module Overview
Ø Understanding Fields in CRM
Ø Configure Field Properties and Display formats
Ø Implement Option set and Two Option Fields
Ø Configure Lookup Fields and Customer Fields
Ø Status and Status Reason
1. Understanding Fields(Column) in CRM
--> Fields stores a value based on Data type (Text, Decimal, lookup etc.)
--> If Entity is a table in SQL, field is a column for that Entity.
Field types:
There are 3 types of Fields available in CRM
1) Simple Field
2) Calculated Field
3) Rollup Field
1. Simple Field:
This field is basically containing data that is not based on a formula.
Ex: Data type for Simple fields are Single line of text, option set, two option set, image, Whole number, floating point number, Decimal number, Currency, Multiple line of text, Date and time, Lookup.
Example: Process for Creating a "Simple Field"
--> Go to Power Apps.
--> Sign in with your credentials
--> Choose the environment where you want to create the custom field.
--> Navigate to Solutions from the left-hand menu.
--> Select an existing solution or create a new one by clicking on + New Solution.
--> Select the Project entity (Here I have selected Project entity, you can select the entity which ever you want to add the Custom field)
--> Under the Fields tab, click on + Add Field.
Display Name: Enter "Project Description".
Name: This will auto-populate based on the display name.
Data Type: Select "Single Line of Text".
Maximum Length: Set the maximum number of characters (e.g., 200).
Required Level: Choose whether the field is optional, business recommended, or business required. Let's set it to optional for this example.
Searchable: Set to Yes if you want the field to be searchable.
Click Done to save the new field.
Save and publish the customizations to make the new field available in the system.
2. Calculated Field:
---> Calculated fields in Model-driven apps are fields whose values are derived from a formula or It contains Calculations that use Fields from the current Entity or Related parent entity.
---> They are useful for automating calculations and aggregations without writing custom code.
---> Data type used here is Single line of text, option set, two option, whole number, decimal number, currency, date and time.
Example: Calculating Total Price in an Order Entity
==> Go to Power Apps.
==> Sign in with your credentials.
==> Choose the environment where you want to create the calculated field.
==> Navigate to Solutions from the left-hand menu.
==> Select an existing solution or create a new one by clicking on + New Solution.
==> Select the Order entity.
==> Under the Fields tab, click on + Add Field.
==> Display Name: Enter "Total Price".
==> Name: This will auto-populate based on the display name.
==> Data Type: Select "Currency".
==> Field Type: Select "Calculated".
==> Click Edit to define the calculation.
==> In the calculation editor, click on + New Condition.
==> Set the conditions for when the calculation should be applied (if any).
==> Click on + Add Action and select Set Field Value.
==> Set the value of the "Total Price" field to the formula: Quantity * Unit Price.
==> Click Save and Close to save the calculation.
Save and Publish Customizations:
==> Save and publish the customizations to make the new calculated field available in the system.
Additional Examples
1. Age Calculation in Contact Entity:
Field Name: Age
Data Type: Whole Number
Calculation: DATEDIFF(year, Birthdate, NOW())
2. Task Completion Percentage in Project Entity:
Field Name: Completion Percentage
Data Type: Decimal Number
Calculation: (Completed Tasks / Total Tasks) * 100
3. Invoice Total in Invoice Entity:
Field Name: Invoice Total
Data Type: Currency
Calculation: SUM(Line Item Amount)
3. Rollup Field:
==> Rollup fields in Model-driven apps are used to aggregate data from related records.
==> They allow you to calculate values such as sums, averages, counts, minimums, and maximums across related records without needing to write custom code.
==> Rollup fields are particularly useful for reporting and analytics, providing real-time aggregated data.
==> Data type used here is Whole number, Decimal number, Currency, Date and time.
Example: Calculating Total Revenue in an Account Entity
==> Go to Power Apps.
==> Sign in with your credentials.
==> Choose the environment where you want to create the rollup field.
==> Navigate to Solutions from the left-hand menu.
==> Select an existing solution or create a new one by clicking on + New Solution.
==> Select the Account entity.
==> Under the Fields tab, click on + Add Field.
==> Display Name: Enter "Total Revenue".
==> Name: This will auto-populate based on the display name.
==> Data Type: Select "Currency".
==> Field Type: Select "Rollup".
==> Click Edit to define the rollup calculation.
==> In the rollup editor, click on + New Condition.
==> Set the conditions for when the calculation should be applied (if any).
==> Click on + Add Action and select Aggregation.
==> Choose the related entity, which in this case is "Opportunity".
==> Select the field to aggregate (e.g., "Estimated Revenue").
==> Choose the aggregation type (e.g., Sum).
==> Set any additional filters or conditions for the related records.
==> Click Save and Close to save the rollup calculation.
==> Save and publish the customizations to make the new rollup field available in the system.
Additional Examples
1) Total Activities in Contact Entity:
Field Name: Total Activities
Data Type: Whole Number
Aggregation: Count of related activity records.
2) Average Order Value in Customer Entity:
Field Name: Average Order Value
Data Type: Currency
Aggregation: Average of order amounts from related order records.
3) Maximum Discount in Sales Entity:
Field Name: Maximum Discount
Data Type: Decimal Number
Aggregation: Maximum of discount values from related sales records.
Field naming Requirement:
Field naming has two important components
Display Name:
==> Display name can be changed
==> If it is displayed in View then it will be column name
==> If it is displayed in Forms then it will be Field Label
==> Display name can be changed in Form editor but not on view Column.
Name:
==> Name cannot be changed
==> Changing display name does not impact the filed name.
==> Used in Plugins, JavaScript and other custom code.
Configure Field Properties and Display formats:
Field Requirements:
· Optional- No Impact
· Business Recommended – Recommended from the business point of view
· Business Required- Mandatory to fill
Searchable:
· A field can be searchable or not (Advanced find or Basic search)
· Can be enabled or disabled
Field Level Security:
· If we want to control the data access, field level security can be enabled.
· When we define field level security on particular Field, we can perform some operation like Read, Write, Create.
Implement Option set and Two Option set:
Option Set:
===> Option set allows us to create a number of choices to select in a field.
===> Options set are used when choices are limited and known
Ex: Payment terms (Advance, 7 days, 30 days, 60days)
===> Two types of Option set we have
Global option set: Can be used for multiple fields on multiple entities.
Local Option Set: can be used for single field on Single entity.
Two Option Set:
==> Two option set are used when there are only possible two values.
Ex: Yes or No, True or False, Active or Inactive.
Lookup Fields and Customer fields:
==> Lookup Fields are used when you want to select a record from an existing entity.
Ex: Account Lookup field on Contact entity.
==> Customer fields are used when you want to lookup to either Accounts or Contact entity records.
Lookup Field Example: Project Management
Entity: Project
Lookup Field: Account
Usage: Each project is linked to an account, allowing users to see which account is responsible for the project.
Customer Field Example: Case Management
Entity: Case
Customer Field: Primary Customer
Usage: Each case can be linked to either an account or a contact, providing flexibility in managing customer issues.
Status and Status Reason
==> In Model-driven apps, the Status and Status Reason fields are used to track the state and detailed status of a record.
==> These fields help users understand the current condition of a record and provide additional context about its state.
Example: Case Management in a Customer Service App
Let's consider a "Case" entity in a customer service app. We'll define the Status and Status Reason fields to track the progress of customer service cases.
==> Go to Power Apps.
==> Sign in with your credentials.
==> Choose the environment where you want to define the Status and Status Reason fields.
==> Navigate to Solutions from the left-hand menu.
==> Select an existing solution or create a new one by clicking on + New Solution.
==> Select the Case entity from the list of entities in the solution.
==> The Status field is typically predefined and contains values such as:
Active
Inactive
The Status Reason field is dependent on the Status field and provides more specific statuses.
Click on the Status Reason field to edit its properties.
Define the Status Reason values for each Status:
For Active status:
New, InProgress, Waiting for Costumer, Escalated
For Inactive status:
Resolved, Closed, Canceled.
==> Save and publish the customization to make the new Status and Status Reason values available in the system.