Merged Change Events
Monitor Change Event Publishing and Delivery Usage
Data Differences in Event Fields
How to Reconstruct a Field from Its Diff Value
Considerations for Newline Characters and Computing the SHA-256 Hash
Previous Versions
To reduce the event payload size and improve performance, Salesforce sometimes sends data differences of updated text values. For large text fields, such as Description or Long Text Area fields that contain at least 1,000 characters, only the data differences might be sent. Data differences use the unified diff format.
Differences are computed for each line in the text value. The diff algorithm breaks the field value into lines by using the line breaks found in the value.
If sending the diff for updates of large text fields does not reduce the field size, the entire value is sent. The diff value is not sent for the following conditions.
For more information about the unified diff format and the diff utility, see the Diff Utility Wikipedia article.
The diff value includes an SHA-256 hash value that is computed on the entire updated value. Use the hash value to verify that the reconstructed value matches the original value before it was converted to a diff. To do so, compute the SHA-256 hash after expanding the diff value. Then compare the two hash values to ensure that they’re equal. If the reconstructed content is different from the original content, the hash value is different. To compute an SHA-256 hash value, you can use a utility such as the UNIX sha256sum command or the DigestUtils class from the Apache Commons library.
Data Differences in Event Fields
When the updated text field value is sent as a diff, it contains the SHA-256 hash value and data differences in the unified diff format.
How to Reconstruct a Field from Its Diff Value
The value of a diff field is in the unified diff format. Use a diff utility to obtain the full field value from the diff.
Considerations for Newline Characters and Computing the SHA-256 Hash
The content that Salesforce uses to generate the SHA-256 hash might have newline characters transformed by the browser. Many browsers transform newline characters to \r\n in record field values before records are stored in Salesforce. Also, Salesforce trims leading and trailing white spaces in field values.