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
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:
Last updated
Was this helpful?
Was this helpful?
<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:
- "<" -> "<"
- ">" -> ">"
- (") -> """
-->
<!--
-> 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://[^/"]*/([a-zA-Z0-9]{18}|[a-zA-Z0-9]{15})(?=(?:/)?")"/>
</SFDCRecordImageUtilConfig>