---
id: post/yzhums-com/51041
type: post
title: "Dynamics 365 Business Central: How to check if a string contains particular strings (if a string is a substring of another)"
summary: "This post explains two methods to check if a string contains a substring in Business Central using AL code: the Text.StrPos method returns the position of the first occurrence, while Text.Contains returns a boolean value. Both approaches are demonstrated with table extension examples."
tier: community
language: en
tags:
  - string checking
  - substring search
  - al development
  - text methods
system: development
review:
  state: reviewed
  by: opus
  at: "2026-10-26T06:41:30.725Z"
  flags: []
generated:
  at: "2026-10-26T05:51:10.938Z"
  pipeline: 0.2.0
  prompts:
    extract-post: 1
  input_hash: b79dcf0ec3a89a453c14e3ac9b575eb1fc3e8cf7261068af50801546e6e6ccb4
evidence:
  - kind: blog
    url: https://yzhums.com/51041/
    title: "Dynamics 365 Business Central: How to check if a string contains particular strings (if a string is a substring of another)"
    date: "2025-11-26"
    commit: null
    t: null
    quote: null
  - kind: blog
    url: https://yzhums.com/51041/
    title: "Dynamics 365 Business Central: How to check if a string contains particular strings (if a string is a substring of another)"
    date: "2025-11-26"
    commit: null
    t: null
    quote: "Text.StrPos(Text, Text) Method: Searches for the first occurrence of substring inside a string."
  - kind: blog
    url: https://yzhums.com/51041/
    title: "Dynamics 365 Business Central: How to check if a string contains particular strings (if a string is a substring of another)"
    date: "2025-11-26"
    commit: null
    t: null
    quote: "Text.Contains(Text) Method: Returns a value indicating whether a specified substring occurs within this string."
links:
  learn: []
  objects:
    - object/table/36
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  related:
    - to: https://learn.microsoft.com/dynamics365/business-central/dev-itpro/developer/types-of-events-for-extensibility
      title: Types of events for extensibility
      label: possibly related
      why: names Table 36 "Sales Header"
      by: code
    - to: https://learn.microsoft.com/dynamics365/business-central/dev-itpro/developer/devenv-walktrough-designing-reports-multiple-tables
      title: Walkthrough - Designing a report from multiple tables
      label: possibly related
      why: names Table 36 "Sales Header"
      by: code
post_id: "51041"
source_id: yzhums-com
source_name: Dynamics 365 Lab - Yun Zhu
url: https://yzhums.com/51041/
published_at: "2025-11-26T02:17:30.000Z"
author: Yun Zhu
full_text: false
words: 327
quotes:
  - text: "Text.StrPos(Text, Text) Method: Searches for the first occurrence of substring inside a string."
    why_it_matters: This is one of two main approaches for finding substrings, showing the foundational method available in AL
  - text: "Text.Contains(Text) Method: Returns a value indicating whether a specified substring occurs within this string."
    why_it_matters: This is the simpler, more modern alternative method that directly answers the question of substring existence
code_objects_mentioned:
  - table Sales Header
systems:
  - development
versions_mentioned: []
preview:
  embeddable: true
  frame_url: null
  image: https://yzhums.com/wp-content/uploads/2025/11/Snipaste_2025-11-25_16-48-03.png
  image_alt: null
  image_w: null
  image_h: null
  site_name: Dynamics 365 Lab
  favicon: https://yzhums.com/wp-content/uploads/2020/08/cropped-logo-3-32x32.png
  probed_at: "2026-10-26T06:11:36.212Z"
---

# Dynamics 365 Business Central: How to check if a string contains particular strings (if a string is a substring of another)

[Read the post](https://yzhums.com/51041/) · Dynamics 365 Lab - Yun Zhu (Yun Zhu, MVP) · 2025-11-26 · 327 words · tier community · reviewed (checked by Opus)

> This post explains two methods to check if a string contains a substring in Business Central using AL code: the Text.StrPos method returns the position of the first occurrence, while Text.Contains returns a boolean value. Both approaches are demonstrated with table extension examples.

## Key points

- Text.StrPos returns the position of the first occurrence of a substring, or zero if it is not found
- StrPos also returns zero when the string or the substring is empty
- Text.Contains returns a boolean telling whether the substring occurs in the string
- For case-insensitive checks, convert both strings first with LowerCase or UpperCase
- Both approaches are shown in a Sales Header table extension using field OnValidate triggers

## Quotes

- "Text.StrPos(Text, Text) Method: Searches for the first occurrence of substring inside a string." (This is one of two main approaches for finding substrings, showing the foundational method available in AL)
- "Text.Contains(Text) Method: Returns a value indicating whether a specified substring occurs within this string." (This is the simpler, more modern alternative method that directly answers the question of substring existence)

## AL objects mentioned

As named in the post. A name that matches one object page by exact type and name links to it; the others stay as named.

- [table 36 "Sales Header"](../../objects/table/36.md)

## Possibly related

No source states these links: they share an object, a model read them, or a person found the same subject.

- [Types of events for extensibility](https://learn.microsoft.com/dynamics365/business-central/dev-itpro/developer/types-of-events-for-extensibility) — possibly related: names Table 36 "Sales Header"
- [Walkthrough - Designing a report from multiple tables](https://learn.microsoft.com/dynamics365/business-central/dev-itpro/developer/devenv-walktrough-designing-reports-multiple-tables) — possibly related: names Table 36 "Sales Header"

## Context

- Features: StrPos method, Contains method, Text comparison, Case-insensitive search

Source: Dynamics 365 Lab - Yun Zhu, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.
