# Rich Text Fields

![](https://2924009365-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5FyPmqVkPxhj2oT8fbgB%2Fuploads%2Fgit-blob-71b908664229d29bfc84f196773579a174ad2e5b%2Fe21a8029-RichText_screen1-1.png?alt=media)

Configure Rich Text Fields for pre-processing before Sending to Salesforce. Options:

* Patch RT Images
  * Replaces all Servlet/RTA Image references with their Base64 encoded image data.
  * *Note:* Upon record insert/update, Salesforce will re-convert the Base64 body to an RTA Image.
* Patch RT URIs
  * Finds and updates Salesforce record IDs embedded in RTA fields. When a record is restored or reinserted with a new ID, this option rewrites hardcoded references to reflect the correct restored record IDs
  * Supported Formats:
    * /001XXXXXXXXXXXXXXX
    * %2Fr%2FObject\_\_c%2F001XXXXXXXXXXXXXXX%2Fview
    * <https://.lightning.force.com/lightning/r/Object__c/001XXXXXXXXXXXXXXX/view>

**NOTE: Only IDs that can be mapped using the Restore’s ID Map or Tracker Database will be replaced. Others remain unchanged. For more information on these functions, see** [**Restore’s ID Map Documentation**](https://learn.capstorm.com/copystorm-restore/reference/migration-setup-tab/migration-record-mapping-tools)**, and** [**Tracker Database Documentation**](https://learn.capstorm.com/copystorm-restore/reference/tracker-database-tab)**.**

![](https://2924009365-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5FyPmqVkPxhj2oT8fbgB%2Fuploads%2Fgit-blob-71dfa54b9c3ce8f88790e31641c3cdabb807a141%2F75a930c4-RichText-screen3.png?alt=media)

## Advanced Use: Rich Text Config XML File

Salesforce records can hold many different formats of images in URLs. Making use of this configuration file allows for the addition of different Regex strings to allow support for new image URL formats in the field.

**Setup**

* Navigate to “CopyStormRestore/Config” directory
* Create an xml file and save it as “SFDCRecordIdTextReplaceUtilConfig.xml” inside of the “CopyStormRestore/config” directory.
* The xml file consists of two tags:
  * The config file opening/closing tag.
  * Regex Entry tags. Each Regex entry tag has two components, a unique name or “type” that is a unique identifier for the entry, as well as a Regex string used to match against URL patterns. The capture group of these Regex strings needs to be the Salesforce ID of the image resource for pre-processing to be successful.

See below for the default configuration file:

```
<SFDCRecordImageUtilConfig>
	<!-- 
		The different types of SFDC image URL formats and their associated REGEXs to
		strip out the target image information.

		SFDC records can hold many different formats of images in URLs. This configuration
		file allows for the addition of different REGEX strings to allow support for new
		image URL formats in the field.

		NOTE: The "<" and ">" characters are reserved in XML and cannot be a part of the "regex"
		parameter. Replace those characters or other XML reserved characters with the following:
			- "<"    ->    "&lt;"
			- ">"    ->    "&gt;"
			- (")	 ->	   "&quot"
	-->

	<!-- 
		-> REGEX String:
			-> (?:/r/[a-zA-Z0-9_]+/)([a-zA-Z0-9]{18}|[a-zA-Z0-9]{15})(?=/|$)

		-> REGEX String Details:
			-> Pattern: (?:/r/[a-zA-Z0-9_]+/)([a-zA-Z0-9]{18})(?=/|$)
				-> (?: ... ): Non-capturing group, meaning it groups the enclosed pattern but does not store the matched value.
				-> /r/: Matches the literal string /r/.
				-> [a-zA-Z0-9_]+: Matches one or more (+) alphanumeric characterse and the underscore. This is used to match
								  to the Salesforce object name in the URL.
				-> /: Matches the literal forward slash (/) after the Salesforce object name in the URL.
				-> ([a-zA-Z0-9]{18}|[a-zA-Z0-9]{15}): Capture group, meaning this is the matched content that is stored. Matches exactly 15 or 18 alphanumeric
									  characters for the Salesforce record ID.
				-> (?=/|$): Ensures that the match is only valid if the capture group is following by a '/', or it is the end of the string

		Parses URLs in the formats:
			-> https://exampleorg.lightning.force.com/lightning/r/Knowledge__kav/001Ec00000L3Pz4IAF/view
			-> https://exampleorg.lightning.force.com/lightning/r/ContentDocument/0696Q00000CTZ9mQAH/view
	-->
	<SFDCImageFormat type="urlIdNoReference" regex="(?:/r/[a-zA-Z0-9_]+/)([a-zA-Z0-9]{18}|[a-zA-Z0-9]{15})(?=/|$)"></SFDCImageFormat>

	<!-- 
		-> REGEX String:
			-> (?:%2Fr%2F[a-zA-Z0-9_]+%2F)([a-zA-Z0-9]{18}|[a-zA-Z0-9]{15})(?=%2F|$)

		-> Pattern: (?:%2Fr%2F[a-zA-Z0-9_]+%2F)([a-zA-Z0-9]{18})(?=/|$)
				-> (?: ... ): Non-capturing group, meaning it groups the enclosed pattern but does not store the matched value.
				-> %2Fr%2F: Matches the URL encoding for the literal String (/r/)
				-> [a-zA-Z0-9_]+: Matches one or more (+) alphanumeric characterse and the underscore. This is used to match
								  to the Salesforce object name in the URL.
				-> %2F: Matches the URL encoding for the literal string forward slash (/).
				-> ([a-zA-Z0-9]{18}|[a-zA-Z0-9]{15}): Capture group, meaning this is the matched content that is stored. Matches exactly 15 or 18 alphanumeric
									  characters for the Salesforce record ID.
				-> (?=%2F|$): Ensures that the match is only valid if the capture group is following by a '/', or it is the end of the string

		-> Parses URLs in the formats (Gets the second ID in the URL):
			-> https://exampleorg.lightning.force.com/lightning/r/Knowledge__kav/001Ec00000L3Q00IAF/view?ws=%2Flightning%2Fr%2FKnowledge__kav%2F001Ec00000L3Q01IAF%2Fview

	-->
	<SFDCImageFormat type="urlIdSingleReference" regex="(?:%2Fr%2F[a-zA-Z0-9_]+%2F)([a-zA-Z0-9]{18}|[a-zA-Z0-9]{15})(?=%2F|$)"></SFDCImageFormat>

	<!-- 
		-> REGEX String:
			-> (?:sfdc://)([a-zA-Z0-9]{18}|[a-zA-Z0-9]{15})

		-> REGEX String Details:
			-> (?:sfdc://)
				-> Non-capturing group to find "sfdc://" right before the capture group
			-> ([a-zA-Z0-9]{18}|[a-zA-Z0-9]{15})
				-> Capture group matching alphanumerics 18 characters in length and if not, 15 characters in length.

		-> Parses rich text in the format:
			-> <p>this is test html<img src="sfdc://001ZZrecord7890123" alt="first tag"/>with two image tags<img src="sfdc://001ZZrecord7890123" alt="second tag"></img></p>
	-->
	<SFDCImageFormat type="sfdcTag" regex="(?:sfdc://)([a-zA-Z0-9]{18}|[a-zA-Z0-9]{15})"></SFDCImageFormat>

	<!--
		-> REGEX String: https://[^/"]*/([a-zA-Z0-9]{15,18})(?=(?:/)?")

		-> REGEX String Details:
			-> https://
				-> Matches the HTTPS protocol
			-> [^/"]*
				-> Non-capture group to match everything after the domain name but stop at the next slash or quote, effectively skipping the host portion
			-> /([a-zA-Z0-9]{18}|[a-zA-Z0-9]{15})
				-> Captures the Salesforce ID after a slash (/) in the 18 or 15 character format
			-> (?=(?:/)?")
				-> Positive look ahead to make sure that after the pattern for the ID is either a quote (") or a slash and quote (/") for termination of the match

		-> Parses rich text in the format:
			-> <p><a href="https://example-data-12345-dev-ed.scratch.my.salesforce.com/kA0Ov000000S6IbKAK" target="_blank">Parent Article</a></p>

	-->
	<SFDCImageFormat type="urlIdNoObjectName" regex="https://[^/&quot;]*/([a-zA-Z0-9]{18}|[a-zA-Z0-9]{15})(?=(?:/)?&quot;)"/>

</SFDCRecordImageUtilConfig>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.capstorm.com/copystorm-restore/reference/restore-set-editor-tab/rich-text-fields.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
