---
id: object/codeunit/20416
type: object
title: Codeunit 20416 "Qlty. Expression Mgmt."
summary: Codeunit 20416 "Qlty. Expression Mgmt." in Quality Management (Microsoft.QualityManagement.Utilities). 12 public procedures, 6 events. Introduced in BC29, still in BC30.
tier: official
language: en
tags:
  - codeunit
  - quality management
versions:
  introduced: "29"
  last_changed: null
  deprecated: null
review:
  state: derived
  by: null
  at: null
  flags: []
generated:
  at: "2026-10-11T00:31:51.816Z"
  pipeline: 0.2.0
  prompts: {}
  input_hash: 1b8051be9ba5df376032c37069257694df686a1dc5819dcb18c6b68c21932c58
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Apps/W1/Quality%20Management/app/src/Utilities/QltyExpressionMgmt.Codeunit.al
    title: src/Apps/W1/Quality Management/app/src/Utilities/QltyExpressionMgmt.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes:
    - change/bcapps/10270
object_type: codeunit
object_id: 20416
name: Qlty. Expression Mgmt.
namespace: Microsoft.QualityManagement.Utilities
app: Quality Management
extends: null
first_version: "29"
last_version: "30"
present_in:
  - "29"
  - "30"
changed_in: []
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 24
  events: 6
  subscribers: 0
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 3
  called_by: 5
  implements: 0
---

# Codeunit 20416 "Qlty. Expression Mgmt."

> Codeunit 20416 "Qlty. Expression Mgmt." in Quality Management (Microsoft.QualityManagement.Utilities). 12 public procedures, 6 events. Introduced in BC29, still in BC30.

Quality Management · Microsoft.QualityManagement.Utilities · BC29-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Apps/W1/Quality%20Management/app/src/Utilities/QltyExpressionMgmt.Codeunit.al) · facts from BC29

## Events published

- `OnEvaluateTextExpressionOnInspectionLine(var QltyInspectionLine: Record "Qlty. Inspection Line"; CurrentQltyInspectionHeader: Record "Qlty. Inspection Header"; var QltyInspectionTemplateLine: Record "Qlty. Inspection Template Line"; ExpressionInput: Text; var ExpressionResultOutput: Text)` (integration): Occurs before a text expression is evaluated on an inspection line.
- `OnBeforeEvaluateBuiltInTableLookups(var Input: Text; var CurrentQltyInspectionHeader: Record "Qlty. Inspection Header"; var CurrentQltyInspectionLine: Record "Qlty. Inspection Line"; var Result: Text; var IsHandled: Boolean)` (integration): Allows system replacement before evaluation of built-in table lookups.
- `OnEvaluateCustomTableFieldInExpression(var Input: Text; var CurrentQltyInspectionHeader: Record "Qlty. Inspection Header"; var CurrentQltyInspectionLine: Record "Qlty. Inspection Line"; var EntireTextBeingEvaluated: Text; var TableName: Text; var NumberOrNameOfFieldName: Text; var EntireFindText: Text; var EntireReplaceText: Text)` (integration): Integration event for evaluating custom table field references in expressions.
- `OnBeforeEvaluateTableFieldInExpression(var EntireTextBeingEvaluated: Text; var TableName: Text; var NumberOrNameOfFieldName: Text; var EntireFindText: Text; var EntireReplaceText: Text; var IsHandled: Boolean)` (integration): Use this to supplement or replace the [specialtable:fieldname] nomenclature when using text expressions. Set Handled to true to completely replace the default behavior in the loop. Set Handled to false to just extend it.
- `OnBeforeEvaluateStringOnlyFunctionThreeParamExpression(var EntireTextBeingEvaluated: Text; var StringFunction: Text; var Param1: Text; var Param2: Text; var Param3: Text; var EntireFindText: Text; var EntireReplaceText: Text; var IsHandled: Boolean)` (integration): Use this to supplement or replace the [stringfunction(param1;param2;param3)] nomenclature when using text expressions. Set Handled to true to completely replace the default behavior in the loop. Set Handled to false to just extend it.
- `OnEvaluateCustomStringOnlyFunctionThreeParamExpression(var EntireTextBeingEvaluated: Text; var StringFunction: Text; var Param1: Text; var Param2: Text; var Param3: Text; var EntireFindText: Text; var EntireReplaceText: Text)` (integration): Use this to add your own string only functions [stringfunction(param1;param2;param3)] nomenclature when using text expressions.

## Procedures

- `EvaluateTextExpression(var QltyInspectionLine: Record "Qlty. Inspection Line"; CurrentQltyInspectionHeader: Record "Qlty. Inspection Header"): Text` (internal): Evaluates a text expression on an inspection line for a specific inspection. Validates that the line is a text expression field type and matches its template configuration. Behavior: - Validates value type is "Value Type Text Expression" - Retrieves expression formula from template line - Evaluates ...
- `EvaluateTextExpression(Input: Text; CurrentQltyInspectionHeader: Record "Qlty. Inspection Header"): Text` (internal): Evaluates a text expression, using fields on the quality inspection as text replacement options. Does *not* evaluate embedded expressions. Provides simplified overload with only inspection header context. Token replacement: Replaces [FieldName] tokens with actual field values from inspection header....
- `EvaluateTextExpression(Input: Text; CurrentQltyInspectionHeader: Record "Qlty. Inspection Header"; CurrentQltyInspectionLine: Record "Qlty. Inspection Line"): Text` (internal): Evaluates a text expression, using fields on the quality inspection as text replacement options. Does *not* evaluate embedded expressions. Supports both inspection header and inspection line field references. Token replacement: Replaces [FieldName] tokens with actual field values from inspection hea...
- `EvaluateTextExpression(Input: Text; CurrentQltyInspectionHeader: Record "Qlty. Inspection Header"; EvaluateEmbeddedNumericExpressions: Boolean): Text` (internal): Evaluates a text expression, using fields on the quality inspection as text replacement options. Set EvaluateEmbeddedNumericExpressions to true to evaluate embedded expressions. Internal overload for controlling embedded expression evaluation without line context.
- `EvaluateTextExpression(Input: Text; CurrentQltyInspectionHeader: Record "Qlty. Inspection Header"; SpecificQltyInspectionLine: Record "Qlty. Inspection Line"; EvaluateEmbeddedNumericExpressions: Boolean): Text` (internal): Evaluates a text expression, using fields on the quality inspection as text replacement options. Set EvaluateEmbeddedNumericExpressions to true to evaluate embedded expressions. Core evaluation method supporting full context and embedded expression evaluation. Features: - Token replacement: [FieldNa...
- `EvaluateExpressionForRecord(Input: Text; RecordVariant: Variant; FormatText: Boolean): Text` (internal): This will replace [fieldname] tokens with the field value for the supplied data.
- `TextReplace(Input: Text; SearchFor: Text; ReplaceWith: Text): Text` (internal): Replaces all occurrences of a search string with a replacement string (case-sensitive by default). Simplified overload using case-sensitive comparison.
- `TextReplace(Input: Text; SearchFor: Text; ReplaceWith: Text; QltyCaseSensitivity: Enum "Qlty. Case Sensitivity"): Text` (internal): Replaces all occurrences of a search string with a replacement string. Supports case-sensitive or case-insensitive matching. Algorithm: Iterative search-and-replace maintaining original casing in output for matched portions. Use cases: - Case-sensitive: Exact token replacement in expressions - Case-...
- `ConvertCarriageReturnsToHTMLBRs(Input: Text): Text` (internal): Converts carriage return and line feed characters to HTML line breaks.
- `ConvertHTMLBRsToCarriageReturns(Input: Text): Text` (internal): Converts supported HTML line break elements to carriage return and line feed pairs.
- `TestEvaluateSpecialStringFunctions(Input: Text): Text` (internal): **** Only used for validation**** Do not use for completely evaluating a string expression. Tests whether special string functions can be parsed without executing full evaluation. Used for validation during template design to catch syntax errors early. Validated functions: CLASSIFY(), REPLACE(), COP...
- `GetTextFormulaOptions(): Text` (internal): Gets available text formula options as a CSV string for reference/documentation. Returns supported token patterns and function syntaxes for text expressions. Returned patterns include: - Field tokens: [Item:No.], [ATTRIBUTE:AttributeName], [Measure:Min.Value] - Functions: CLASSIFY(), REPLACE(), COPY...

Plus 6 local procedures.

## Calls

From the extracted call graph of BC29 (graphify-al on the snapshot checkout): calls whose target is known from a declared type or an `Object::"Name"` argument. Interface dispatch and calls through events are not counted, so the list is not complete.

- [Codeunit 3960 "Regex"](../codeunit/3960.md) (4 calls: `EvaluateBuiltInTableLookups → Groups`, `EvaluateBuiltInTableLookups → Match`, `EvaluateFirstStringOnlyFunctions → Groups`, …)
- [Codeunit 20403 "Qlty. Filter Helpers"](../codeunit/20403.md) (3 calls: `LookupFieldValueBasedOn → IdentifyFieldIDFromText`, `LookupFieldValueBasedOn → IdentifyTableIDFromText`, `LookupFieldValueBasedOn → SetFiltersByExpressionSyntax`)
- [Codeunit 20599 "Qlty. Misc Helpers"](../codeunit/20599.md) (3 calls: `EvaluateBuiltInTableLookups → ReadFieldAsText`, `EvaluateExpressionForRecord → GetRecordRefFromVariant`, `LookupFieldValueBasedOn → ReadFieldAsText`)

## Called by

- [Codeunit 20424 "Qlty. Workflow Response"](../codeunit/20424.md) (2 calls: `HandleOnExecuteWorkflowResponse → EvaluateTextExpression`, `InitDispositionBufferFromWorkflowStepArgument → EvaluateTextExpression`)
- [Page 20440 "Qlty. Inspection Template Edit"](../page/20440.md) (2 calls: `RunModalWith → ConvertCarriageReturnsToHTMLBRs`, `RunModalWith → ConvertHTMLBRsToCarriageReturns`)
- [Codeunit 20410 "Qlty. Result Evaluation"](../codeunit/20410.md) (1 call: `ValidateAllowableValuesOnInspectionLine → EvaluateTextExpression`)
- [Page 20406 "Qlty. Inspection"](../page/20406.md) (1 call: `GetDataCaptionExpression → EvaluateTextExpression`)
- [Table 20406 "Qlty. Inspection Line"](../table/20406.md) (1 call: `EvaluateTextExpression → EvaluateTextExpression`)

## Recent changes

- 2026-08-20 [#10270 [Quality Management] Repair and improve XML documentation of procedures](../../changes/bcapps/10270.md) (main, BC30, refactor)

## Across versions

- Present in: BC29-30
- Changed (declaration) in: none

Source: AL metadata extracted from the code (names, ids, signatures, properties); no code bodies (D10).

## Ask your agent

Procedure bodies are not stored here (D10). The call sections above are our own, per object, from the BC29 call graph. For a procedure body or the calls of one procedure, ask bc-code-atlas (external, by Stefan Maron, MIT; default corpus w1-28), which the bc-observatory plugin connects: `bcatlas_resolve_node(object_type: "codeunit", object_name: "Qlty. Expression Mgmt.")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
