web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Power app code (react)...
Power Apps
Answered

Power app code (react) and dataverse bulk operations

(1) ShareShare
ReportReport
Posted on by 9

Hi everyone,

I’m developing a Power Apps Code App (React + VS Code) connected to a Dataverse database.

Using pac code add-data-source, I connected my app to the Dataverse tables and generated the corresponding service classes. These services allow me to perform basic Dataverse operations (create, update, delete, get, getAll) using the authenticated Power Platform user.

However, I’m now facing limitations when dealing with more complex scenarios.

For example, suppose I have a GroupItem entity (with a corresponding Dataverse table) that contains a collection of Items (another table). The real scenario is more complex, but let’s keep it simple for clarity.

I need to duplicate a GroupItem along with all its related Items.

Currently, I can:

  • Retrieve the GroupItem

  • Loop through its Items

  • Call service.create() for each Item

  • Manage the parent-child relationships manually

The problem is that this approach is very slow because it results in one separate Dataverse call per Item.

So my questions are:

  • What is the recommended approach for handling heavy or complex Dataverse operations efficiently?

  • Would it be better to implement something like a server-side “DuplicateGroup” function (Custom API, Action, or similar) within the Power Platform and call it from my React app with parameters?

  • Ideally, I would also like to:

    • Execute this logic using the authenticated Power Platform user

    • Be able to trigger it on a schedule (without user interaction in the app)

What would be the best architectural approach for this scenario?

Thanks in advance for your help!

Fabrice

I have the same question (0)
  • Verified answer
    VASANTH KUMAR BALMADI Profile Picture
    176 on at

    You’re running into a real Dataverse limitation, not a Code App problem — and your instinct is correct: client-side duplication is the wrong layer for this kind of workload.

    What you’re seeing (one Web API call per child record) is exactly why Microsoft does not recommend handling complex entity graphs from Power Apps Code Apps or Canvas Apps.

    ✅ Recommended architecture (what Microsoft expects you to do)

    For heavy or multi-record Dataverse operations, the correct pattern is:

    Client (React / Power Apps) → single server-side Dataverse operation → bulk logic executed inside Dataverse

    That server-side operation should be one of the following:

    Custom API (preferred)

    Action (Dataverse classic)

    ⚠️ Plug-in (only if you need deep pipeline access)

    Why your current approach is slow

    Your Code App is doing this:

    React
     ├─ GET GroupItem
     ├─ GET Items (n records)
     ├─ POST Item #1
     ├─ POST Item #2
     ├─ POST Item #3
     ├─ ...
    

    That means:

    • multiple HTTPS round trips

    • Dataverse throttling

    • no transaction scope

    • no batching support from pac services

    • no parallel execution guarantees

    Even 100 related records becomes painfully slow.

    ✅ Best solution: Custom API inside Dataverse

    This is exactly what Custom APIs were built for.

    What you create in Dataverse

    A Custom API called something like:

    DuplicateGroupItem
    

    Input parameters

    • GroupItemId (GUID)

    Output

    • NewGroupItemId (GUID)

    Inside the Custom API (server-side)

    Implement logic using:

    • Plug-in registered to the Custom API

    • Dataverse SDK

    • ExecuteMultipleRequest

    Example logic flow:

    1. Retrieve GroupItem
    2. Retrieve all related Items
    3. Create new GroupItem
    4. Clone Items in memory
    5. Insert Items using ExecuteMultiple
    6. Return new GroupItem Id
    

    All of this runs:

    • inside Dataverse

    • in the same region

    • in a single transaction context

    • without HTTP latency

    Performance difference is massive.

    ✅ Benefits of Custom API approach

    ✔ One call from React
    ✔ Executes as authenticated Power Platform user
    ✔ Supports impersonation
    ✔ Can be reused anywhere
    ✔ Much faster
    ✔ Centralized business logic
    ✔ Transaction support
    ✔ Works with thousands of related records

    This is exactly how Microsoft handles:

    • Quote → Quote Lines copy

    • Opportunity → Products

    • Case duplication

    • Order cloning

    🔐 Running as the authenticated user

    Custom APIs support:

    • CallerId execution

    • Full Dataverse security model

    • Row-level and column-level security

    • Audit history

    So the records will show:

    “Created by: John Smith”

    —not by a service account.

    ⏱️ Scheduled execution requirement

    Since the logic is server-side, you get this for free.

    You can trigger the same Custom API from:

    • Power Automate (scheduled flow)

    • Azure Function

    • Logic Apps

    • Dataverse workflow

    • React Code App

    No UI required.

    🔁 How React calls it

    From your Code App, you just call the Custom API endpoint:

    POST /api/data/v9.2/DuplicateGroupItem
    

    with:

    {
      "GroupItemId": "GUID"
    }
    

    That’s it.

    One call. Everything else happens inside Dataverse.

    ❌ What not to use

    Option Why not
    Client-side looping Slow, throttled
    Canvas formulas Not scalable
    Power Automate per-record loops Even slower
    Virtual tables Not transactional
    Direct SQL Not supported
    pac service classes CRUD only

    ⚠️ Plugin vs Custom API

    Use:

    • Custom API + plug-in → business operation

    • Plug-in alone → event-based logic (Create/Update)

    For duplication, Custom API is the correct choice.

    ✅ Final recommended architecture

    Power Apps Code App (React)
              ↓
    Single call to Custom API
              ↓
    Dataverse plug-in logic
              ↓
    ExecuteMultiple bulk insert
              ↓
    Return new GroupItemId
    

    Summary

    Yes — your assumption is correct.

    ✔ Do NOT duplicate complex entity graphs in the client
    ✔ Do NOT loop Dataverse calls from React
    ✔ Implement a server-side Custom API
    ✔ Execute logic inside Dataverse
    ✔ Call it from the app with parameters
    ✔ Reuse it from scheduled Power Automate flows

    This is the same pattern Microsoft uses internally for all complex Dataverse operations.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Kalathiya Profile Picture

Kalathiya 460

#2
WarrenBelz Profile Picture

WarrenBelz 381 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 330 Super User 2025 Season 2

Last 30 days Overall leaderboard