You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: powerapps-docs/developer/data-platform/bulk-operations.md
+148-4Lines changed: 148 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Use bulk operation messages
3
3
description: Learn how to use special APIs to perform operations on multiple rows of data in a Microsoft Dataverse table.
4
-
ms.date: 11/13/2023
4
+
ms.date: 02/08/2024
5
5
author: divkamath
6
6
ms.author: dikamath
7
7
ms.reviewer: jdaly
@@ -20,7 +20,7 @@ To get the best performance when you run operations on multiple rows of a Micros
20
20
21
21
-[`CreateMultiple`](#createmultiple): Creates multiple records of the same type in a single request.
22
22
-[`UpdateMultiple`](#updatemultiple): Updates multiple records of the same type in a single request.
23
-
-[`UpsertMultiple` (preview)](upsertmultiple.md): Creates or updates multiple records of the same type in a single request.
23
+
-[`UpsertMultiple`](upsertmultiple.md): Creates or updates multiple records of the same type in a single request.
24
24
-[`DeleteMultiple` (preview)](deletemultiple.md): For elastic tables only. Deletes multiple records of the same type in a single request.
25
25
26
26
> [!NOTE]
@@ -137,6 +137,7 @@ Updates multiple records of the same type in a single request.
137
137
138
138
Just like when you update individual records, the data you send with `UpdateMultiple` must contain only the values you're changing. Learn how to [update records with SDK for .NET](org-service/entity-operations-update-delete.md) and [update records with the Web API](webapi/update-delete-entities-using-web-api.md#basic-update).
139
139
140
+
140
141
##### [SDK for .NET](#tab/sdk)
141
142
142
143
Uses the [UpdateMultipleRequest class](xref:Microsoft.Xrm.Sdk.Messages.UpdateMultipleRequest).
@@ -221,6 +222,151 @@ OData-Version: 4.0
221
222
222
223
Multiple records with the same primary key or alternate key values in the payload are not supported with `UpdateMultiple`. When more than one record in the `Targets` parameter is uniquely identified by a primary or alternate key, the operation is performed on the first record only. Any subsequent records with the same key value(s) in the payload are ignored.
223
224
225
+
### UpsertMultiple
226
+
227
+
Use `Upsert` to integrate data with external sources when you don't know whether the table exists in Dataverse or not.`Upsert` operations frequently depend on alternate keys to identify records. Use `UpsertMultiple` to perform `Upsert` operations in bulk.
228
+
229
+
##### [SDK for .NET](#tab/sdk)
230
+
231
+
Uses the [UpsertMultipleRequest class](xref:Microsoft.Xrm.Sdk.Messages.UpsertMultipleRequest).
232
+
233
+
This static `UpsertMultipleExample` method depends on a `samples_bankaccount`table that has a string column named
234
+
`samples_accountname` configured as an alternate key. It also has a string column named `samples_description`. This code uses the [Entity constructor that sets the keyName and keyValue](use-alternate-key-reference-record.md#using-the-entity-class) to specify the alternate key value.
235
+
236
+
```csharp
237
+
/// <summary>
238
+
/// Demonstrates using UpsertMultiple with alternate key values
Within [Sample: SDK for .NET Use bulk operations](org-service/samples/create-update-multiple.md), look for the [UpsertMultiple project](https://github.com/microsoft/PowerApps-Samples/blob/master/dataverse/orgsvc/C%23-NETCore/BulkOperations/UpsertMultiple/README.md)
305
+
306
+
##### [Web API](#tab/webapi)
307
+
308
+
Uses the [UpsertMultiple action](xref:Microsoft.Dynamics.CRM.UpsertMultiple).
309
+
310
+
> [!IMPORTANT]
311
+
>
312
+
> - You must set the `@odata.type` property for each item in the `Targets` parameter.
313
+
> - The `UpsertMultiple` action returns `204 NoContent`. The `UpsertMultipleResponse` complex type is not returned.
314
+
315
+
The following example shows using the `UpsertMultiple` action with a standard table named `sample_example`.
316
+
These requests identify the records using an alternate key defined using a column named `sample_keyattribute`.
317
+
The `@odata.id` annotation identifies the record with a relative URL as described in [Use an alternate key to reference a record](use-alternate-key-reference-record.md)
318
+
319
+
**Request**
320
+
321
+
```http
322
+
POST [Organization Uri]/api/data/v9.2/sample_examples/Microsoft.Dynamics.CRM.UpsertMultiple
`UpsertMultiple` is available for tables that support `CreateMultiple` and `UpdateMultiple`. This includes all elastic tables. The queries found in [Availability with standard tables](bulk-operations.md#availability-with-standard-tables) will not return results for `UpsertMultiple`, but you can use them to detect whether a table supports both `CreateMultiple` and `UpdateMultiple`.
369
+
224
370
225
371
## Standard and elastic table usage
226
372
@@ -293,8 +439,6 @@ When you use the Web API to perform a bulk operation on an elastic table, you ne
293
439
Bulk operation message availability depends on whether you're using standard tables or elastic tables. All elastic tables support the `CreateMultiple`, `UpdateMultiple`, `UpsertMultiple`, and `DeleteMultiple` messages.
0 commit comments