Skip to content

Commit f4bc0a3

Browse files
authored
Merge branch 'main' into patch-6
2 parents f3ab366 + b1eaa7f commit f4bc0a3

File tree

2 files changed

+39
-26
lines changed

2 files changed

+39
-26
lines changed

powerapps-docs/developer/data-platform/use-upsert-insert-update-record.md

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Use Upsert to insert or update a record (Microsoft Dataverse) | Microsoft Docs" # Intent and product brand in a unique string of 43-59 chars including spaces
33
description: "UpsertRequest(Update or Insert) message helps you simplify various data integration scenarios where you do not know if a record already exists in Microsoft Dataverse. In such cases you won’t know if you should call an UpdateRequest or a CreateRequest operation. This results in your querying for the record first to determine if it exists before performing the appropriate operation. UpsertRequest message helps you solve that issue" # 115-145 characters including spaces. This abstract displays in the search result.
4-
ms.date: 03/22/2022
4+
ms.date: 04/08/2022
55
ms.reviewer: "pehecke"
66
ms.topic: "article"
77
author: "divka78" # GitHub ID
@@ -25,44 +25,47 @@ You can reduce the complexity involved with data integration scenarios by using
2525

2626
<a name="BKMK_UsingUpsert"></a>
2727

28-
## Using Upsert
28+
## Using Upsert
29+
2930
It is best to use <xref:Microsoft.Xrm.Sdk.Messages.UpsertRequest> only when you aren’t sure if the record exists. That is, when you aren’t sure if you should call a <xref:Microsoft.Xrm.Sdk.Messages.CreateRequest> or an <xref:Microsoft.Xrm.Sdk.Messages.UpdateRequest> operation. There is a performance decrease in using <xref:Microsoft.Xrm.Sdk.Messages.UpsertRequest> versus using <xref:Microsoft.Xrm.Sdk.Messages.CreateRequest>. If you are sure the record doesn’t exist, use <xref:Microsoft.Xrm.Sdk.Messages.CreateRequest>.
3031

31-
The <xref:Microsoft.Xrm.Sdk.Messages.UpsertRequest> includes a property named <xref:Microsoft.Xrm.Sdk.Messages.UpsertRequest.Target>. This property contains the table definition that will be used in an <xref:Microsoft.Xrm.Sdk.Messages.UpdateRequest> or a <xref:Microsoft.Xrm.Sdk.Messages.CreateRequest> operation. It also includes all the columns required by the <xref:Microsoft.Xrm.Sdk.Messages.CreateRequest> for the target table type so that the record can be created if it doesn’t exist.
32+
The <xref:Microsoft.Xrm.Sdk.Messages.UpsertRequest> includes a property named <xref:Microsoft.Xrm.Sdk.Messages.UpsertRequest.Target>. This property contains the entity instance that will be used in an <xref:Microsoft.Xrm.Sdk.Messages.UpdateRequest> or a <xref:Microsoft.Xrm.Sdk.Messages.CreateRequest> operation. It also includes all the columns required by the <xref:Microsoft.Xrm.Sdk.Messages.CreateRequest> for the target entity so that the record can be created if it doesn’t exist.
3233

3334
You can inspect <xref:Microsoft.Xrm.Sdk.Messages.UpsertResponse.RecordCreated> to determine if the record was created. <xref:Microsoft.Xrm.Sdk.Messages.UpsertResponse.RecordCreated> will be true if the record didn’t exist and was created. It will be false if the record already existed and was updated. <xref:Microsoft.Xrm.Sdk.Messages.UpsertResponse.Target> will be an `EntityReference` to the record that was found to exist or to the record that was created.
3435

3536
To understand how <xref:Microsoft.Xrm.Sdk.Messages.UpsertRequest> works, see the following section.
3637

37-
<a name="BKMK_upsert"></a>
38+
<a name="BKMK_upsert"></a>
39+
3840
## Understanding the Upsert process
41+
3942
The following steps describe the processing logic when an <xref:Microsoft.Xrm.Sdk.Messages.UpsertRequest> is received:
4043

4144
1. Send <xref:Microsoft.Xrm.Sdk.Messages.UpsertRequest> with enough data for a create or insert operation.
4245

43-
2. Dataverse will look up the record targeted by the target table.
46+
2. Dataverse will look up the record targeted by the target entity.
4447

4548
3. If the record exists:
4649

47-
1. Set the ID property of the target table with the ID of the found record.
50+
1. Set the ID property of the target entity with the ID of the found record.
4851

4952
2. Call Update.
5053

5154
3. Set the <xref:Microsoft.Xrm.Sdk.Messages.UpsertResponse.RecordCreated> to `false`.
5255

53-
4. Create an <xref:Microsoft.Xrm.Sdk.EntityReference> from the target table of the update as the value for <xref:Microsoft.Xrm.Sdk.Messages.UpsertResponse.Target>.
56+
4. Create an <xref:Microsoft.Xrm.Sdk.EntityReference> from the target entity of the update as the value for <xref:Microsoft.Xrm.Sdk.Messages.UpsertResponse.Target>.
5457

5558
5. Return the <xref:Microsoft.Xrm.Sdk.Messages.UpsertResponse>.
5659

5760
4. If the record doesn’t exist:
5861

59-
1. Copy any alternate key values that the target does not already have in its attributes collection, into the target table columns.
62+
1. Copy any alternate key values that the target does not already have in its attributes collection, into the target entity attributes.
6063

6164
2. Call `Create`.
6265

6366
3. Set the <xref:Microsoft.Xrm.Sdk.Messages.UpsertResponse.RecordCreated> to `true`.
6467

65-
4. Create an <xref:Microsoft.Xrm.Sdk.EntityReference> from the target table type and the ID result of the `Create` request as the value for <xref:Microsoft.Xrm.Sdk.Messages.UpsertResponse.Target>.
68+
4. Create an <xref:Microsoft.Xrm.Sdk.EntityReference> from the target entity and the ID result of the `Create` request as the value for <xref:Microsoft.Xrm.Sdk.Messages.UpsertResponse.Target>.
6669

6770
5. Return the <xref:Microsoft.Xrm.Sdk.Messages.UpsertResponse>.
6871

@@ -72,11 +75,12 @@ You can reduce the complexity involved with data integration scenarios by using
7275

7376
<a name="BKMK_SampleCode"></a>
7477

75-
## Sample code
76-
The [Insert or update a record using Upsert](/samples/browse/) sample [ProductUpsertSample.cs](https://code.msdn.microsoft.com/Insert-or-update-a-record-aa160870/sourcecode?fileId=136218&pathId=1243320355) file contains the following `ProcessUpsert` method to apply the `UpsertRequest` message on the contents of an XML file to create new records or update existing ones.
78+
## Sample code
79+
80+
The [SampleMethod.cs](https://github.com/microsoft/PowerApps-Samples/blob/master/cds/orgsvc/C%23/InsertRecordUsingUpsert/InsertRecordUsingUpsert/SampleMethod.cs) file in the [Insert record using Upsert](https://github.com/microsoft/PowerApps-Samples/tree/master/cds/orgsvc/C%23/InsertRecordUsingUpsert/InsertRecordUsingUpsert) sample contains the following `ProcessUpsert` method to apply the `UpsertRequest` message on the contents of an XML file to create new records or update existing ones.
7781

7882
```csharp
79-
public void ProcessUpsert(String Filename)
83+
public static void ProcessUpsert(CrmServiceClient service, String Filename)
8084
{
8185
Console.WriteLine("Executing upsert operation.....");
8286
XmlTextReader tr = new XmlTextReader(Filename);
@@ -97,15 +101,15 @@ public void ProcessUpsert(String Filename)
97101
productToCreate["sample_name"] = productName;
98102
productToCreate["sample_category"] = productCategory;
99103
productToCreate["sample_make"] = productMake;
100-
UpsertRequest request = new UpsertRequest()
104+
var request = new UpsertRequest()
101105
{
102106
Target = productToCreate
103107
};
104108

105109
try
106110
{
107111
// Execute UpsertRequest and obtain UpsertResponse.
108-
UpsertResponse response = (UpsertResponse)_serviceProxy.Execute(request);
112+
var response = (UpsertResponse)service.Execute(request);
109113
if (response.RecordCreated)
110114
Console.WriteLine("New record {0} is created!", productName);
111115
else
@@ -117,22 +121,15 @@ public void ProcessUpsert(String Filename)
117121
{
118122
throw;
119123
}
120-
121124
}
122-
// Prompts to view the sample_product entity records.
123-
// If you choose "y", IE will be launched to display the new or updated records.
124-
if (PromptForView())
125-
{
126-
ViewEntityListInBrowser();
127-
}
128-
129125
}
130126
```
131127

132-
### See also
133-
[Use change tracking to synchronize data with external systems](use-change-tracking-synchronize-data-external-systems.md)
134-
[Define alternate keys for a table](define-alternate-keys-entity.md)
135-
[Using alternate keys](use-alternate-key-create-record.md)
128+
### See also
129+
130+
[Use change tracking to synchronize data with external systems](use-change-tracking-synchronize-data-external-systems.md)
131+
[Define alternate keys for a table](define-alternate-keys-entity.md)
132+
[Using alternate keys](use-alternate-key-create-record.md)
136133

137134

138135
[!INCLUDE[footer-include](../../includes/footer-banner.md)]

powerapps-docs/mobile/powerapps-mobile-troubleshoot.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,22 @@ To resolve connection related issues, ensure you remain connected to the interne
126126

127127
The Flow action menu in Power Apps mobile doesn't support flows created in a solution.
128128

129+
## App resets when running it on Power Apps mobile
130+
131+
When you run a canvas or model-driven app on Power Apps mobile it can reset if the app is using too many resources. If the app uses more resources than are available on your device, the app will reset. This is similar to when you visit a large complex webpage, and the web browser suspends the page because it is consuming too much power.
132+
133+
Power Apps mobile is designed to run on a wide range of devices, including low-end devices with limited resources. When you create a canvas or model-driven app, remember to optimize the app to run on the lowest specificized device that your end-users will use.
134+
135+
If you experience a reset, contact your app developer, and point them to this topic.
136+
137+
For more information for developers, see:
138+
139+
- Blog post: [PowerApps coding standards and guidelines](https://powerapps.microsoft.com/blog/powerapps-canvas-app-coding-standards-and-guidelines/)
140+
- Whitepaper: [PowerApps canvas app coding
141+
standards and guidelines](https://pahandsonlab.blob.core.windows.net/documents/PowerApps%20canvas%20app%20coding%20standards%20and%20guidelines.pdf) (Note, review the section titled, **Optimizing for performance**).
142+
143+
144+
129145
### See also
130146

131147
[Power Apps portals known issues](../maker/portals/known-issues.md) <br/>

0 commit comments

Comments
 (0)