Get Started with Microsoft Canvas App

Microsoft Canvas App – A Practical Guide for Power Platform Developers

Canvas Apps are one of the most flexible offerings in the Microsoft Power Platform. They allow developers to design custom user experiences using a low-code approach while still supporting complex business logic.

This blog explains what a Canvas App is, where it excels, where it struggles, real-world use cases, supported data sources, and provides a comprehensive overview of components and Power Fx functions, accompanied by brief explanations.

Canvas App Overview


What is a Canvas App?

A Canvas App lets you design your app screen-by-screen with full control over layout and behavior. You place controls like labels, buttons, galleries, and forms wherever you want and define logic using Power Fx.

Canvas Apps are UI-first, making them perfect for mobile apps, custom workflows, and task-based solutions.


What Makes Canvas Apps Awesome

  • Full control over UI and user experience
  • Rapid development with low-code formulas
  • Works well for mobile-first and custom apps
  • Supports many data sources beyond Dataverse
  • Easy integration with Power Automate

Where Canvas Apps Fall Short (Compared to Model-Driven Apps)

  • Handling complex relational data is harder
  • No built-in business process flows
  • Security must be handled manually in some cases
  • Performance can degrade with large datasets

Business Scenarios – When to Use Canvas Apps

  • Field inspection and survey apps
  • Employee self-service portals
  • Approval and request management
  • Inventory and asset tracking
  • Custom mobile apps for sales teams

Data Sources Supported by Canvas Apps

  • Dataverse
  • SharePoint
  • Excel (OneDrive / SharePoint)
  • SQL Server (Azure & On-Prem via Gateway)
  • Microsoft Lists
  • Dynamics 365
  • Custom APIs using Custom Connectors

Canvas App Components (Purpose + Working)

Label

Displays static or dynamic text on the screen.


Text = "Hello " & User().FullName

Text Input

Accepts user input such as names, emails, or numbers.


TextInput1.Text

Button

Triggers an action when clicked.


OnSelect = SubmitForm(Form1)

Gallery

Shows a list of records in a repeating layout.


Items = Employees

Form (Edit / Display)

Used to create, update, or view records.


DataSource = Employees

Dropdown

Allows selection of a single value from a list.


Items = Distinct(Employees, Department)

ComboBox

Advanced dropdown with multi-select and search.


SelectedItems

Date Picker

Lets users select a date.


SelectedDate

Toggle

Captures Yes/No input.


Toggle1.Value

Checkbox

Used for boolean selections.


Checkbox1.Value

Icon

Clickable icon used for actions.


OnSelect = Remove(Employees, ThisItem)

Timer

Runs logic after a set time interval.


OnTimerEnd = Refresh(Employees)

Component (Custom)

Reusable UI with encapsulated logic.


Input / Output properties


Top 25 Most Used Power Fx Functions

1. Patch

Creates or updates records in a data source.


Patch(DS, Defaults(DS), {Name:"Ajay"})

2. SubmitForm

Saves form data to the connected data source.


SubmitForm(Form1)

3. Collect

Adds records to a local collection.


Collect(colData, DS)

4. ClearCollect

Clears and reloads a collection.


ClearCollect(colData, DS)

5. Filter

Returns records that meet a condition.


Filter(DS, Status="Active")

6. LookUp

Finds the first matching record.


LookUp(DS, Email=User().Email)

7. Remove

Deletes a specific record.


Remove(DS, ThisItem)

8. RemoveIf

Deletes records based on condition.


RemoveIf(DS, Status="Inactive")

9. UpdateIf

Updates records conditionally.


UpdateIf(DS, Status="New", {Status:"Closed"})

10. If

Runs logic based on conditions.


If(IsBlank(txt.Text), Notify("Required"))

11. Switch

Executes logic based on multiple conditions.


Switch(Role, "Admin", true, false)

12. Navigate

Navigates to another screen.


Navigate(Screen2)

13. Notify

Displays in-app notifications.


Notify("Saved", NotificationType.Success)

14. Set

Creates or updates global variables.


Set(varUser, User().Email)

15. UpdateContext

Creates screen-level variables.


UpdateContext({locVisible:true})

16. Concurrent

Runs multiple actions in parallel.


Concurrent(Refresh(A), Refresh(B))

17. IsBlank

Checks if a value is blank.


IsBlank(TextInput1.Text)

18. IsEmpty

Checks if a table or collection is empty.


IsEmpty(colData)

19. CountRows

Counts records in a table.


CountRows(Gallery1.AllItems)

20. Sum

Calculates total of numeric values.


Sum(Sales, Amount)

21. Text

Formats values as readable text.


Text(Today(), "dd-mm-yyyy")

22. Value

Converts text to numeric value.


Value(TextInput1.Text)

23. Today

Returns current system date.


Today()

24. Now

Returns current date and time.


Now()

25. Refresh

Reloads latest data from source.


Refresh(DS)

Remember, every great Canvas App started with a single control on a blank screen. Experiment, explore, and don't be afraid to try new ideas.

Keep learning, keep creating, and enjoy the ride! 🌟



🌐 Understanding Dynamics 365 CE & Dataverse

 Whether you're just starting your journey as a Dynamics 365 Developer or preparing for that big interview, everything begins with a clear understanding of what you're actually building on. That means understanding what Dynamics 365 CE is, and more importantly, how Dataverse holds it all together.

Let’s break it down.

💡 What is Dynamics 365 CE?

When we say Dynamics 365 Customer Engagement (CE), we’re talking about a collection of Microsoft business applications focused on managing customer-facing processes. Think about:

  • 💼 Sales – for tracking leads, opportunities, and closing deals

  • 🎧 Customer Service – for handling cases, SLAs, and knowledge management

  • 📣 Marketing – for managing campaigns, segments, customer journeys

  • 🧰 Field Service – for dispatching technicians and managing assets

  • 📊 Project Operations – for managing resource utilization and project billing

All of these apps don’t live in isolation. They run on a shared platform called Dataverse.


🧠 So, What Exactly Is Dataverse?

You can think of Dataverse as the "database with superpowers."

It's not just where data is stored — it's the backbone of all Power Platform applications and Dynamics 365 CE modules. It handles things like:

  • Tables (Entities) – like Contact, Account, or Case

  • Relationships – one-to-many, many-to-many

  • Security roles & access control

  • Business logic – workflows, business rules, calculated fields

  • APIs – for developers to read/write/update data

🔍 Fun Fact: Dataverse was formerly known as Common Data Service (CDS). Microsoft rebranded it, but many principles are the same.


🏗️ Dataverse = A Developer’s Playground

If you're a D365 developer, here’s what makes Dataverse special for you:

  • You can customize tables, fields, and relationships without writing code.

  • You can write plugins to run server-side logic during operations like create/update/delete.

  • You can integrate external systems using the Web API or the SDK.

  • You can build rich Power Automate flows or Power Apps that talk directly to Dataverse.

In other words, it gives you the flexibility of a relational database with the power of a business platform.


🔐 Security Model in Dataverse

Security isn’t an afterthought — it’s baked in.

Dataverse provides a layered security model:

  • Business Units – Logical segregation of users (e.g., by department or geography)

  • Security Roles – Define what actions a user can perform (Read, Write, Delete, etc.)

  • Teams – Users can belong to multiple teams and inherit access

  • Hierarchy Security – Managers can access records of their reports

🛡️ This model ensures that data access is well-governed — a crucial need for enterprise-grade apps.


💬 Real-World Analogy

Imagine you're building an app to manage real estate assets. Dataverse lets you:

  • Create a A Property table with custom columns like Area, Price, Location

  • Link each property to an Owner (Account)

  • Restrict certain users to only see properties in their city (via business units)

  • Run a plugin to auto-calculate stamp duty based on the price

All of this happens inside Dataverse, without needing to build your own backend from scratch.


🎯 Interview Questions

1. What are the core components of the Power Platform?
Ans. Power Apps, Power Automate, Power BI, Power Pages, and Dataverse.

2. What is Dataverse?
Ans. Cloud-based data platform for storing and managing business data.

3. Difference between Dataverse and traditional SQL?
Ans. Dataverse offers metadata-driven logic, relationships, security, and integration support.

4. How is metadata stored and managed in Dataverse?
Ans. Metadata (like table schema, relationships) is stored in system tables and drives the platform's dynamic behavior.

5. What’s the difference between model-driven and canvas apps?
Ans. Model-driven apps are data-first (based on Dataverse), canvas apps are design-first (pixel control).

6. What’s the role of business units?
Ans. They define the data access boundary for users.

7. What is a business unit in D365 CE and how does it impact data access?
Ans. It creates a hierarchy that controls the visibility of records to users based on their assigned unit.

8. Can we control field-level security in Dataverse?
Ans. Yes, via Field Security Profiles

9. What is the difference between record ownership and access?
Ans. Ownership gives control over a record; access (via sharing, role, or team) allows interaction without owning.

10. What are Access Teams vs Owner Teams?
Ans. Owner Teams own records; Access Teams are temporary and used for granting record-level access dynamically.

11. What is the role of a solution in D365 CE?
Ans. A container to group and transport customizations like tables, fields, views, and flows.

12. Managed vs Unmanaged solutions?
Ans. Managed = for deployment, Unmanaged = for development.

13. Can we export a solution with data? If yes, how?
Ans. No, solutions don’t carry data. Use Data Export Service, Azure Data Factory, or dataflows.

14. What is patching in managed solutions?
Ans. Patches allow delivering small updates over a base managed solution, useful for hotfixes.

15. What is the difference between a patch and a clone of a solution?
Ans. A patch makes a small update to an existing solution; a clone creates a new major version that includes all prior patches.

16. Can you export a managed solution from a production environment?
Ans. No, only unmanaged solutions can be exported. Managed solutions are meant for deployment, not modification.

17. What happens if two managed solutions customize the same component?
Ans. The solution installed last wins (layering). Managed conflicts are resolved via solution layering.

18. What happens when you delete a managed solution from an environment?
Ans. All components included in that solution (that weren’t used elsewhere) are removed, making it risky in production.

18. Can you explain the solution layering model in D365 CE?
Ans. D365 uses a layered solution model:
        System Layer → Managed → Unmanaged.
        The top-most layer takes precedence.

19. What are polymorphic lookups in Dataverse (also called Customer or Regarding)?
Ans. These allow referencing more than one type of table (e.g., Customer can link to either Account or Contact).

20. Which APIs can developers use to access Dataverse?
Ans. Web API (REST), SDK via IOrganizationService (SOAP), and Data Export (for external sync).

21. What are some limitations of Dataverse developers should be aware of?
Ans. Some key limitations:
  • API limits (service protection throttling)
  • Complex joins are harder than in SQL
  • Plugin execution timeout (~2 minutes)
  • Storage can become expensive at scale



How to Get and Set Field Values in Dynamics 365 CRM using JavaScript

Get & Set Field Values in Dynamics 365 | JavaScript Guide
Dynamics 365 · JavaScript

Get & Set Field Values
in Dynamics 365

A complete JavaScript reference for all CRM field types

JavaScript formContext Power Platform CRM Automation
Customizing Dynamics 365 CRM using JavaScript allows you to dynamically retrieve and update field values, improving user experience and automation. This guide covers getValue() and setValue() patterns for every field type you'll encounter in a CRM form.

Getting Started

Every JavaScript customization in Dynamics 365 starts with getting the form context from the execution context. All field operations flow through this object.

Entry Point
JavaScript
function GetSet(executionContext) {
    var formContext = executionContext.getFormContext();
}

01Single Line & Multiple Lines of Text

📝 Used for textual data entry. Both single-line and multi-line text fields share the same getValue() and setValue() API.
Get Value
JavaScript
var name = formContext.getAttribute("xyz_name").getValue();
Set Value
JavaScript
formContext.getAttribute("xyz_name").setValue("John Doe");

02Two Options (Boolean) Fields

Stores Yes/No or True/False values. getValue() returns a boolean; setValue() accepts true or false.
Get Value
JavaScript
var interested = formContext.getAttribute("xyz_interested").getValue();
Set Value
JavaScript
formContext.getAttribute("xyz_interested").setValue(true);

03Option Set (Dropdown) Fields

📊 Used for predefined selections. You can get/set by numeric ID or by text label. Setting by text requires looping through the available options.
Get Selected Value (Numeric ID)
JavaScript
var topic = formContext.getAttribute("xyz_topic").getValue();
Get Selected Text
JavaScript
var topicText = formContext.getAttribute("xyz_topic").getText();
Set Value Using ID
JavaScript
formContext.getAttribute("xyz_topic").setValue(772500003);
Set Value Using Text
JavaScript
var text = "Power Automate";
var optionSetValues = formContext.getAttribute("xyz_topic").getOptions();

for (var i = 0; i < optionSetValues.length; i++) {
    if (optionSetValues[i].text == text) {
        formContext.getAttribute("xyz_topic").setValue(optionSetValues[i].value);
    }
}

04Whole Number Fields

🔢 Used for storing integer values. getValue() returns a number; setValue() accepts a whole number.
Get Value
JavaScript
var age = formContext.getAttribute("xyz_age").getValue();
Set Value
JavaScript
formContext.getAttribute("xyz_age").setValue(30);

05Decimal & Floating Point Numbers

🔣 Used for precise numeric values. Decimal fields store fixed-precision numbers; floating point fields store approximate values with higher range.
Get Decimal Value
JavaScript
var dn = formContext.getAttribute("xyz_dn").getValue();
Set Decimal Value
JavaScript
formContext.getAttribute("xyz_dn").setValue(45.6);
Get Floating Point Value
JavaScript
var fpn = formContext.getAttribute("xyz_fpn").getValue();
Set Floating Point Value
JavaScript
formContext.getAttribute("xyz_fpn").setValue(0.00008);

06Date Fields

📅 Used to store date and date-time values. getValue() returns a JavaScript Date object; pass a Date object to setValue().
Get Value
JavaScript
var dateField = formContext.getAttribute("xyz_date").getValue();
Set Value (Current Date)
JavaScript
formContext.getAttribute("xyz_date").setValue(new Date());

07Currency Fields

💰 Stores financial values. Works identically to decimal fields — returns a number and accepts a number. The currency symbol is controlled by the record's currency setting.
Get Value
JavaScript
var amount = formContext.getAttribute("xyz_amount").getValue();
Set Value
JavaScript
formContext.getAttribute("xyz_amount").setValue(876.78);

08Multi-Select Option Set Fields

☑️ Allows selecting multiple predefined values. getValue() returns an array of numeric IDs; setValue() takes an array. Setting by text requires matching each label against getOptions().
Get Selected Values (Array of IDs)
JavaScript
var selectedValues = formContext.getAttribute("xyz_country").getValue();
Get Selected Texts
JavaScript
var selectedTexts = formContext.getAttribute("xyz_country").getText();
Set Values Using IDs
JavaScript
formContext.getAttribute("xyz_country").setValue([772500000, 772500002, 772500005]);
Set Values Using Texts
JavaScript
var selectedOptions = [];
var optionText = ["India", "Brazil", "Canada"];
var optionSetValues = formContext.getAttribute("xyz_country").getOptions();

for (var i = 0; i < optionText.length; i++) {
    for (var j = 0; j < optionSetValues.length; j++) {
        if (optionText[i] === optionSetValues[j].text) {
            selectedOptions.push(optionSetValues[j].value);
        }
    }
}
formContext.getAttribute("xyz_country").setValue(selectedOptions);

09Lookup & Customer Fields

🔗 Used to reference records like Contacts and Accounts. getValue() returns an array with one object containing id, entityType, and name. setValue() takes the same structure.
Get Lookup Record Details
JavaScript
var lookupValue = formContext.getAttribute("xyz_author").getValue();

var authorGuid       = lookupValue ? lookupValue[0].id         : null;
var authorEntityType = lookupValue ? lookupValue[0].entityType : null;
var authorName       = lookupValue ? lookupValue[0].name       : null;
Set Lookup Value
JavaScript
var lookupRecord = [{
    id:         "0d849e72-362b-eb11-a813-000d3af010d0",
    entityType: "contact",
    name:       "John Doe"
}];

formContext.getAttribute("xyz_author").setValue(lookupRecord);

Conclusion

Understanding how to get and set field values in Dynamics 365 using JavaScript helps improve form automation and user experience. By leveraging these scripting techniques, you can customize CRM behavior efficiently — from simple text fields to complex lookups and multi-select options.


FAQs

Q1 Can I update fields dynamically based on other field values?
Yes. Use the onChange event to trigger scripts when a field's value changes. Register your function on the field's OnChange event in the form editor, and it will fire every time the user modifies that field.
Q2 How do I reset a field to blank?
Pass null to setValue(). This works for all field types.
JavaScript
formContext.getAttribute("xyz_fieldname").setValue(null);
Q3 Where do I place this JavaScript code in Dynamics 365?
Create a Web Resource (type: JavaScript) in your solution, paste your function there, and then link it to the form's events — such as OnLoad or OnChange — through the form editor's event handler settings.

Tip: Always check that getValue() doesn't return null before reading properties from the result — especially for Lookup fields. A quick null check prevents the most common runtime errors in CRM scripts.

Dynamics 365 · JavaScript · Power Platform · CRM Customization Guide

How to Get Latitude and Longitude from an Address Using Bing Maps API in JavaScript for D365

 

Getting Latitude & Longitude from an Address Using Bing Maps API


In Microsoft Dynamics 365, capturing latitude and longitude based on a given address is crucial for various business scenarios, such as the following:

  • Customer Location Tracking: Storing precise geolocation details for customers.

  • Field Service Optimization: Assigning technicians based on customer locations.

  • Sales Territory Management: Mapping sales territories.

To achieve this, we use the Bing Maps API to convert an input address into geographic coordinates (latitude and longitude) and auto-populate them in Dynamics 365 fields.