Blocks
The JSON objects that store the rich-text content are composed of two main parts: blocks and entityMaps.
A block is a JSON object that represents a single-line of formatted text. Since a single custom field can have more than one line of text, each line of text has its own block, and each block is represented as an element in a parent array called blocks.
Example: Here, each line of text from a custom field maps to a block element in the array blocks.
Since each block element is also a JSON object, each block is composed of the elements: key, text, type, depth, inlineStyleRanges, entityRanges, and data. Each of these elements functions as the following:
- Key: The unique identifier for that block. The key is used to map a line of text via entityMaps. Details about entityMaps can be found in the entityMaps section of this document.
- Text: The line of text content that is being stored from the custom field.
- Type: Describes the type of text that is being represented. For example, a line of text being stored in a block could be a part of a list. If that line of text was a part of an unordered list, then its type would be defined as: unordered-list-item.
- Lists: Currently not supported, but should be available soon.
- Depth: A parameter that defines the depth of the line when the line is a nested part of an ordered or unordered list.
- inlineStyleRanges: An array that describes the type(s) of formatting that were applied to the line of text represented by the current block.
Example: Here is an inlineStyleRanges array that describes each style at the character level. In this case: 9 characters (length: 9) starting from the index 0 (offset: 0) had the style Bold applied:
In the case where multiple types of formatting have been applied to a single line, styles will be mapped to additional elements in the inlineStyleRanges array.
Example: Here is what a block would look like when storing a line of text that contains the mixed formatting: Bold text and Italics.
entityMaps and entityRanges
A block of data can potentially contain entities like hyperlinks or other types of stylized formatting that are connected to data sources located outside of the custom text field.
Examples
Retrieving plain text from JSON
When a custom field with rich-text formatting is submitted, all of the text is stored in the array blocks. However, each line of the full text is stored in the text parameter within each of the separate block elements that make up the parent array blocks. So in order to retrieve the full text, each separate line of text needs to be extracted and parced back together. This can be achieved by looping over all of the elements in blocks and concatenating each text parameter together, with a line delimiter (\n).
Example: Here is what your JS might look like:
Saving a rich text field value using the Workfront API
To save the following values of a rich-text field using the Workfront API:
Hello World!!!
This is my first Rich Text
-
Construct JSON that represents the value of the rich-text field you are trying to capture by organizing each line of text into a block element in the array blocks.
-
Capture the rich-text formatting using the inlineStyleRanges parameter.
-
To capture the second line, the text Rich Text must be formatted in both bold and italics.
NOTE
While entityMap functionality isn’t supported during the initial release, it’s still a required field to pass this JSON in a request. -
Use the stringify method on the JSON outlined above to make a PUT request and send updates.
More help on this topic
Was this content helpful?
Announcements
Get hands-on with agentic AI.
Explore how AI agents work together through real examples and hands-on practice. Join your local User Group to design an agent workflow with your peers and leave with a practical framework you can apply to your own work.
Find an eventTransamerica’s Thrilling Journey to Workfront V2
Join the Transamerica team for a candid look at their Workfront V2 migration: the planning, the surprises, and lessons learned.
Workfront Fusion Office Hours: Get more from the new scenario designer (option 1)
Join the Workfront Fusion teams for an open session on the updated scenario designer - bring your questions and feedback! All Fusion users welcome, no prep needed.
Unified Review and Approvals: Your Questions Answered by the Product Team
Join the Product team for a Q&A session to address your outstanding questions related to Unified Review & Approvals in Workfront. Please submit your question(s) during registration!