Loading...

Extend Your Solutions: Custom API + Field Mapping in Dataverse

Extend Your Solutions: Custom API + Field Mapping in Dataverse

Dataverse powers the heart of the Microsoft Power Platform, offering a rich relational data layer and a suite of tools for makers and developers. While low-code configurations can solve many business needs, there comes a point when complex business logic demands more.

Enter Custom APIs—your way to encapsulate server-side logic in a secure, reusable, and solution-aware package. Combine this with Field Mapping—which ensures automatic data population between related tables—and you unlock a powerful pattern for building sophisticated enterprise apps.

In this post, we’ll do a deep technical dive into:

  • What Custom APIs and Field Mapping are
  • Why they’re better together
  • Real-world scenarios
  • Best practices
  • Pitfalls to avoid

What is a Custom API?

Custom APIs let you define your own operations in Dataverse, complete with input/output parameters and server-side logic. Unlike workflows or Power Automate flows, they’re built for high performance and enterprise ALM.

Features of Custom APIs

  • Entity-bound or global
  • Secure (role-based access)
  • Plugin integration for C/JavaScript logic
  • Solution-aware for ALM pipelines
  • Callable from Power Apps, Power Automate, or even external systems

Example: Create a `SubmitServiceRequest` API that accepts `CustomerId` and `PriorityLevel`, and returns a `ConfirmationNumber`.

What is Field Mapping?

Field Mapping defines how attributes from one table populate another during create or update operations.

Say you're creating a Work Order from a Case:

  • `Case.Title` → `WorkOrder.Name`
  • `Case.Customer` → `WorkOrder.Account`
  • `Case.Address` → `WorkOrder.Service Location`

This ensures consistency without manual intervention.

Why Combine Custom API and Field Mapping?

By combining both:

  • Custom APIs handle business logic (create child record, call external APIs, enforce validations).
  •  Field Mapping automatically pre-fills related data.

This pattern creates clean separation of concerns:

  • No duplicated UI logic
  • Easier testing
  • Faster iterations

Real-World Use Case: Field Service Automation

Problem

When a case is escalated, you need to:

  • Create a Work Order.
  • Auto-populate customer info.
  • Send notifications.

Solution

  • Custom API handles creation and notifications.
  • Field Mapping pre-fills customer-related fields.

How to Implement (Step by Step)

Define a Custom API

In Dataverse:

 Go to Solutions > New > Custom API

 Set:

  • Name: `SubmitServiceRequest`
  • Binding Type: Entity-bound (bind to `incident`)
  • IsPrivate: `No`

Create Plugin Logic

public void Execute(IServiceProvider serviceProvider)

{

    var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

    var service = (IOrganizationService)serviceProvider.GetService(typeof(IOrganizationService));


    Guid customerId = (Guid)context.InputParameters["CustomerId"];

    string priority = (string)context.InputParameters["PriorityLevel"];


    var workOrder = new Entity("msdyn_workorder")

    {

        ["customerid"] = new EntityReference("account", customerId),

        ["prioritycode"] = priority == "High" ? 1 : 2

    };


    Guid woId = service.Create(workOrder);

    context.OutputParameters["ConfirmationNumber"] = $"WO-{woId.ToString().Substring(0, 8)}";

}

Register this plugin step to your Custom API.

Configure Field Mapping

In the `incident → msdyn_workorder` relationship:

Map:

  • title` → `name`
  • customerid` → `serviceaccount`
  • `description` → `instructions`

Call from Power Apps

Patch(

    'SubmitServiceRequest',

    Defaults('SubmitServiceRequest'),

    {

        CustomerId: GUID(txtCustomerId.Text),

        PriorityLevel: drpPriority.Selected.Value

    }

)

Power Automate:

 Dataverse Connector → Perform a bound action → Select `SubmitServiceRequest`

Benefits


Limitations



Best Practices


Summary

Combining Custom APIs and Field Mapping allows you to build powerful, reusable, and maintainable enterprise-grade solutions in Dataverse. It separates UI from business logic while reducing duplication and ensuring consistent data handling.

Whether you’re a pro developer or a solution architect, this pattern will level up your Dataverse projects.

Published on:

Learn more
Power Platform , D365 CE & Cloud
Power Platform , D365 CE & Cloud

Dynamics 365 CE, Power Apps, Powerapps, Azure, Dataverse, D365,Power Platforms (Power Apps, Power Automate, Virtual Agent and AI Builder), Book Review

Share post:

Related posts

Power Platform Environment Deep Dive (Part 2)

In Microsoft Power Platform, choosing the right environment type is important because each environment is designed for a different business pu...

1 day ago

Power Platform Environment Deep Dive (Part 1)

Today, in the business enterpriese world, Power Platform enables organization to build application, automate workflow, analyze data  crea...

3 days ago

Book Review : Life 3.0 by Max Tegmark

This is the third book I’ve read this year, and even though I’m still in the early chapters, it already feels like my favorite read of the yea...

1 month ago

Dataverse Views Demystified: Making Data Work for You

In Microsoft Dataverse, users do not always see all the data stored in a table. What they can view depends on their security permissions, role...

2 months ago

Decode & Fix : Shared App host initialization has timed out in Microsoft Power Apps

 Issue :While working with apps in the Microsoft Power Platform, we encountered a critical issue where the application failed to load pro...

4 months ago

Dataverse Integration Patterns: Sync vs Async vs Event-driven (Real Use Cases)

As organizations start using Microsoft Power Platform, Microsoft Dataverse is no longer just a place to store data—it becomes a key part of ho...

4 months ago

Book Review : Don't Believe Everything You Think by Joseph Nguyen

My second book of this year is "Don’t Believe Everything You Think" by Joseph Nguyen. This book was recommended by a friend who strongly belie...

5 months ago

Book Review : Scary Smart by Mo Gawdat

The first book I read in 2026 was Scary Smart by Mo Gawdat, the former Chief Business Officer at Google.In today’s world, Artificial Intellige...

6 months ago

Managing Temporary User Access in Dataverse with Access Teams

Access Teams let you give people access to one specific record, not the whole table.Access Teams in Microsoft Dataverse are a powerful way to ...

6 months ago

Newsletter

Get the latest Dynamics 365 and Power Platform content in your inbox

A curated digest of community blogs, product news, videos, and podcasts — delivered without the noise.

Weekly updates Unsubscribe anytime Fresh community picks
We use your email only for the newsletter and you can unsubscribe at any time.
By subscribing, you agree to the privacy policy.