---
title: "Fix stripHtmlTags 2,003-Char Limit in Workday Orchestrate"
description: "Work around the silent 2,002-character tag limit in Workday Orchestrate's stripHtmlTags and htmlToPlainText functions when rich text includes base64 images."
url: https://kiweely.com/guides/workday-orchestrate-striphtmltags-2003-character-limit
---

# Why stripHtmlTags and htmlToPlainText Leave HTML Tags Over 2,003 Characters in Workday Orchestrate

In Workday Orchestrate, stripHtmlTags and htmlToPlainText can silently leave individual HTML tags of 2,003 or more characters—such as inline base64 <img> tags—unaltered. Strip oversized base64 tags or use proper XML/HTML escaping before sending rich text downstream.

-   **Checked** against Workday on November 6
-   Applies to **Workday Orchestrate**
-   3 min read
-   Published November 6
-   By Kiweely

## Silent Failure on HTML Tags of 2,003 or More Characters

Workday Orchestrate provides three `Text` member functions for reducing HTML markup in rich-text fields (such as Workday performance feedback, job descriptions, or candidate notes):

-   `.stripHtmlTags()` — Removes HTML/XML tags while leaving HTML entities encoded.
-   `.htmlToPlainText()` — Converts block-level tags (`<p>`, `<div>`, `<br>`, `<li>`, `<h1>`–`<h6>`) into line breaks, strips inline tags, collapses whitespace runs, and decodes HTML entities.
-   `.sanitizeHtml(allowedTags: String)` — Removes all HTML/XML tags except those listed in the comma-separated `allowedTags` parameter (and always removes `<script>` and `<style>` elements).

When rich-text fields from Workday contain embedded base64 images (`<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..." />`) or long inline `style` attributes where a **single HTML tag** is **2,003 characters or longer**, earlier runtime versions of `.stripHtmlTags()` and `.htmlToPlainText()` hit an internal parser buffer boundary at 2,002 characters. Instead of throwing a runtime exception, the functions **silently skip the oversized tag** and return the entire `<img src="data:image/..."/>` tag unaltered in the output string while stripping normal short tags (`<p>`, `<b>`, `<div>`) around it.

Furthermore, if a rich-text string is truncated upstream so that it ends inside an unterminated tag (an opening `<` bracket with no matching closing `>` bracket), `.stripHtmlTags()`, `.htmlToPlainText()`, and `.sanitizeHtml()` can throw a step execution error.

* * *

## Security Scope: LLM Prompt Preparation vs. HTML/XSS Sanitization

As documented in **Reference: Text Member Functions**, `.stripHtmlTags()`, `.htmlToPlainText()`, and `.sanitizeHtml()` are designed specifically to reduce HTML markup in small rich-text snippets before sending text to a Large Language Model (LLM) or plain-text target. They are **not** general HTML sanitizers and must **not** be used as a security control against HTML tag injection or Cross-Site Scripting (XSS) in rendered HTML reports:

1.  **Unfiltered Attributes on Allowed Tags:** `.sanitizeHtml("b,i,a")` preserves allowed tags verbatim, including all attributes (`onerror=...` or `href="javascript:..."`).
2.  **Unsafe Entity Decoding in `htmlToPlainText()`:** `.htmlToPlainText()` decodes numeric and hexadecimal character references without safe-decoding filtering, including references that resolve to control characters, bidirectional text override characters, or zero-width characters.
3.  **Oversized Tag Passthrough:** Any unstripped tag over 2,002 characters on affected runtime builds passes directly into the output document.

* * *

## Pre-Cleaning Embedded Base64 Images and Unterminated Tags in Orchestrate

When processing Workday Rich Text fields that may contain embedded base64 images or arbitrary user markup, pre-process the string before calling `.stripHtmlTags()` or `.htmlToPlainText()`:

### Step 1: Strip Inline `<img ...>` Tags in a Loop or Substring Expression

Because Orchestrate’s `String` member functions (`.replace()`, `.substringBefore()`, `.substringAfter()`) operate on literal substrings rather than full regular expressions, you can strip embedded `<img` tags before invoking `.stripHtmlTags()`.

If rich-text fields contain a single inline base64 image or a bounded number of `<img` tags, remove the segment between `<img` and the next `>` using `substringBefore` and `substringAfter` inside a **Create Values** step:

javascript

```
// Remove an embedded <img ...> tag before calling stripHtmlTags()
data.FetchFeedback.richText.contains("<img")
  ? data.FetchFeedback.richText
      .substringBefore("<img")
      .append(data.FetchFeedback.richText.substringAfter("<img").substringAfter(">"))
      .asTEXT()
      .stripHtmlTags()
  : data.FetchFeedback.richText.asTEXT().stripHtmlTags()
```

If a rich-text document can contain multiple embedded base64 `<img` tags across lines or paragraphs, split the string on `"<img"` using `.split("<img")` (which returns a `StringList`), iterate over the segments in a **Loop** step, and strip everything up to the first `">"` on every segment after the first:

javascript

```
// Inside Loop over data.FetchFeedback.richText.split("<img"):
data.LoopImgSegments.index == 0
  ? data.LoopImgSegments.item
  : data.LoopImgSegments.item.contains(">")
    ? data.LoopImgSegments.item.substringAfter(">")
    : ""
```

Aggregate the loop output with `.mkString("")`, cast to `Text` with `.asTEXT()`, and call `.stripHtmlTags()`.

### Step 2: Guard Against Unterminated Trailing `<` Brackets

Before passing user-entered text or length-truncated strings into `.stripHtmlTags()` or `.htmlToPlainText()`, ensure the string does not end inside an unclosed `<` bracket (which occurs when an upstream report field truncates a rich-text value mid-tag):

javascript

```
// If the last '<' appears after the last '>', strip the trailing broken fragment
data.CleanedText.rawString.lastIndexOf("<") > data.CleanedText.rawString.lastIndexOf(">")
  ? data.CleanedText.rawString.substring(0, data.CleanedText.rawString.lastIndexOf("<"))
  : data.CleanedText.rawString
```

### Step 3: Escape Output for XML/HTML Targets with `.escapeXml()`

If the orchestration writes the cleaned text into an XML payload or an HTML-formatted report file, chain `.toString().escapeXml()` (or `.escapeToJsonString()` for JSON payloads) after `.stripHtmlTags()` so any residual `<` or `>` characters are converted to `&lt;` and `&gt;` entities and cannot inject markup into the target file.

* * *

## Verifying the Fix in Your Tenant

1.  Create a test payload in **DebugOrchestrations** containing both standard HTML tags (`<p>Annual review summary</p>`) and an `<img src="data:image/png;base64,..." />` tag exceeding 2,500 characters, plus a test case ending with a truncated `<span style="color:red` fragment.
2.  Execute the orchestration in **Orchestration Builder** and inspect the **Create Values** output to verify that the `<img ...>` tag and the truncated trailing `<span` fragment are completely removed and `.stripHtmlTags()` completes with zero remaining `<` or `>` characters.

## Sources checked

-   [Reference: Text Member Functions](https://developer.workday.com/documentation/GUID-2a9723f2-a711-4b67-bdba-9951ccf52064)
-   [Reference: String Member Functions](https://developer.workday.com/documentation/GUID-c22f5c68-87f5-4bd6-ad96-4e0d246e72c3)
-   [Concept: Text Templates](https://developer.workday.com/documentation/GUID-e2785ee9-6d55-4f43-b375-a2e546da6503)
-   [Reference: Create Values](https://developer.workday.com/documentation/GUID-c310de5e-1e37-4ca6-bca3-52033d7ccb18)

## Related guides

[All guides](https://kiweely.com/guides)

-   [### Generating UUIDs with random.randomUUID() and Fixing stringAtJsonPath().toNumber() in Orchestrate Workday Orchestrate uses random.randomUUID() instead of PMD’s UUID() function to generate unique batch IDs, and requires chaining .toNumber() on the outer stringAtJsonPath() function rather than inside the JSONPath literal.](https://kiweely.com/guides/workday-orchestrate-randomuuid-stringatjsonpath-tonumber)
-   [### JSONPath Logical Filter Expressions and Wildcard XPaths in Workday Orchestrate Compound JSONPath filter expressions (&&, ||) in Workday Orchestrate fail silently when typographic quotes are pasted or unsupported filter tokens are chained. Learn the supported JSONPath and wildcard XPath syntax and when to replace SOAP launch polling with Trigger Integration.](https://kiweely.com/guides/workday-orchestrate-jsonpath-logical-filters-xpath-wildcards)
-   [### Why Log to File Turns XML Closing Tags into <// and How to Write #if Conditions in CreateTextTemplate Viewing aggregated XML through a Log to File step in Workday Orchestrate turns every closing tag ‘</’ into ‘<//’ because Log to File defaults its CSV escape character to ‘/’. Use Store Document for XML files, and omit outer parentheses around #if conditions in CreateTextTemplate.](https://kiweely.com/guides/workday-orchestrate-xml-double-slash-log-to-file-if-conditions)
-   [### Sorting JsonKeyValueIterator Collections and Numeric String Values in Workday Orchestrate Loops Workday Orchestrate fails at build time when sorting a JsonKeyValueIterator loop by item.key(), and sorts numeric strings lexicographically (‘1’, ‘1000’, ‘3’). Use a two-loop key extraction pattern for JSON objects and cast string IDs with toNumber() in Loop Sort By.](https://kiweely.com/guides/workday-orchestrate-sort-jsonkeyvalueiterator-numeric-sorting)

### More guides on Orchestrate

[All 86 guides](https://kiweely.com/guides#orchestrate)

-   [Why SendWorkdayRaasRequest returns 401 Unauthorized or empty data via the cloud proxy](https://kiweely.com/guides/workday-orchestrate-sendworkdayraasrequest-401-cloud-proxy)
-   [Reusing and versioning sub-orchestrations across Workday Extend and O4I apps](https://kiweely.com/guides/workday-orchestrate-reuse-sub-orchestrations-across-apps)
-   [Picking up SFTP files from subfolders and reading IDs from PDF filenames in Orchestrate](https://kiweely.com/guides/workday-orchestrate-sftp-subfolders-pdf-files)
-   [Sending email from Orchestrate: the Connect sendMessage API and email connectors](https://kiweely.com/guides/workday-orchestrate-send-email)
-   [How to keep large Workday Orchestrate loads inside the runtime limits: templates, checkpoints, batches and child runs](https://kiweely.com/guides/workday-orchestrate-runtime-limit-large-loads)
-   [How to rebuild an XSLT transformation in Workday Orchestrate](https://kiweely.com/guides/workday-orchestrate-replace-xslt)
-   [RaaS calls in Orchestrate: namespaces, unexpected character errors, 401s and empty reports](https://kiweely.com/guides/workday-orchestrate-raas-errors)
-   [How to process a CSV file in Orchestrate for Integrations, from Document Retrieval to the output file](https://kiweely.com/guides/workday-orchestrate-process-csv-file)

### From the blog on Orchestrate

[All posts](https://kiweely.com/blog)

-   [Codex for Orchestration JSON: Catching the 25-Second Sync Trap Before Deploy](https://kiweely.com/blog/codex-orchestration-json-25-second-sync-trap)
-   [Keep in Studio, Move to Orchestrate, or Rebuild as an Extend App? A Practical Triage Matrix](https://kiweely.com/blog/migrating-legacy-workday-studio-integrations-to-orchestrate-decision-matrix)
-   [How Kiweely Vine designs, builds, deploys, tests and monitors a Workday Orchestration for Integration](https://kiweely.com/blog/workday-orchestration-for-integration-with-kiweely)

## Let Workday check the work.

Kiweely writes WQL and builds orchestrations in your own tenant, and Workday, not Kiweely, says whether they passed.

[Start for free](https://kiweely.com/download) [See how it works](https://kiweely.com/vine/how-it-works)

## Get the next guide in your inbox.

One email a month with new guides and one Extend tip. Nothing else.
