Skip to content

Commit cfcffa2

Browse files
committed
Merging changes synced from https://github.com/MicrosoftDocs/powerapps-docs-pr (branch live)
2 parents 3e2f1d7 + 0fcdb69 commit cfcffa2

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

powerapps-docs/developer/data-platform/best-practices/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
items:
3636
- name: Service Protection API Limits
3737
href: ../api-limits.md
38+
- name: Manage invalid characters
39+
href: work-with-data/invalidcharactersinfield.md
3840
- name: Work with metadata using code
3941
href: work-with-metadata/index.md
4042
items:

powerapps-docs/developer/data-platform/best-practices/work-with-data/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ This list below contains all of the best practices and guidance around integrati
3030
|Best Practice |Description |
3131
|---------|---------|
3232
|[Service protection API limits (Dataverse)](../../api-limits.md) |Understand the limits for API requests. |
33+
|[Manage invalid characters](invalidcharactersinfield.md)| Manage invalid characters |
3334

3435
### See Also
3536

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: "Manage invalid characters | Microsoft Docs"
3+
description: Describes how to manage invalid characters.
4+
5+
ms.date: 08/09/2021
6+
ms.reviewer: "pehecke"
7+
ms.service: powerapps
8+
ms.topic: "article"
9+
author: "JimDaly"
10+
ms.subservice: dataverse-developer
11+
ms.author: "pehecke"
12+
manager: "kvivek"
13+
search.audienceType:
14+
- developer
15+
search.app:
16+
- PowerApps
17+
- D365CE
18+
---
19+
20+
# Manage invalid characters
21+
22+
There are a set of characters that cannot be saved in string or memo columns. When an application saves data containing these characters to Dataverse, the following error will occur:
23+
24+
Name: `InvalidCharactersInField`<br />
25+
Hexadecimal error code : `80040278`<br />
26+
Error Number: `-2147220872`<br />
27+
Description: `The field '{0}' contains one or more invalid characters.`<br />
28+
29+
Dataverse uses the [System.Xml.XmlConvert.VerifyXmlChars(String) Method](/dotnet/api/system.xml.xmlconvert.verifyxmlchars) for every string value passed to these columns. This error is thrown on the first invalid character encountered.
30+
31+
You may encounter these characters in email content that includes replies or when text is copied from another source which may have characters to control presentation.
32+
33+
To prevent this error you can:
34+
35+
- HTML encode the content before saving.
36+
37+
- Remove the individual invalid characters, use the [System.Xml.XmlConvert.IsXmlChar(Char) Method](/dotnet/api/system.xml.xmlconvert.isxmlchar) as shown in the following example:
38+
39+
```csharp
40+
static string RemoveInvalidXmlChars(string text) {
41+
var validXmlChars = text.Where(ch => XmlConvert.IsXmlChar(ch)).ToArray();
42+
return new string(validXmlChars);
43+
}
44+
```
45+
46+
47+
### See Also
48+
49+
[Work with data using code in Dataverse (Power Apps)](../../work-with-data.md)<br />
50+
51+
[!INCLUDE[footer-include](../../../../includes/footer-banner.md)]
52+

0 commit comments

Comments
 (0)