---
id: post/yzhums-com/77663
type: post
title: "Dynamics 365 Business Central: How to pad a string to a specified length with a character (GetPaddedString)"
summary: GetPaddedString is a method in Business Central's StringConversionManagement codeunit that fills a string with a specified character until it reaches a desired length, supporting both left and right justification.
tier: community
language: en
tags:
  - string manipulation
  - al development
  - getpaddedstring
  - codeunit
system: development
review:
  state: reviewed
  by: opus
  at: "2026-11-27T01:03:17.223Z"
  flags: []
generated:
  at: "2026-11-27T00:13:11.976Z"
  pipeline: 0.2.0
  prompts:
    extract-post: 1
  input_hash: 36e27f9fd9cbc1250afe744a0cc6cba99837f2b43414858597dc9f371e1a6c23
evidence:
  - kind: blog
    url: https://yzhums.com/77663/
    title: "Dynamics 365 Business Central: How to pad a string to a specified length with a character (GetPaddedString)"
    date: "2026-11-26"
    commit: null
    t: null
    quote: null
  - kind: blog
    url: https://yzhums.com/77663/
    title: "Dynamics 365 Business Central: How to pad a string to a specified length with a character (GetPaddedString)"
    date: "2026-11-26"
    commit: null
    t: null
    quote: "there is already a very simple method in the standard codeunit 47 StringConversionManagement that can do this: GetPaddedString()."
  - kind: blog
    url: https://yzhums.com/77663/
    title: "Dynamics 365 Business Central: How to pad a string to a specified length with a character (GetPaddedString)"
    date: "2026-11-26"
    commit: null
    t: null
    quote: If the original string is already longer than PadLength, GetPaddedString() does not truncate the string.
links:
  learn: []
  objects:
    - object/codeunit/47
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  related:
    - to: post/yzhums-com/75649
      title: "Dynamics 365 Business Central: How to quickly remove Non-Alphanumeric Characters in AL"
      label: possibly related
      why: both name Codeunit 47 "StringConversionManagement"
      by: code
    - to: post/aardvarklabs-blog/2741
      title: "Understanding AL Development: String Conversion Management Code Unit"
      label: possibly related
      why: both name Codeunit 47 "StringConversionManagement"
      by: code
post_id: "77663"
source_id: yzhums-com
source_name: Dynamics 365 Lab - Yun Zhu
url: https://yzhums.com/77663/
published_at: "2026-11-26T04:25:51.000Z"
author: Yun Zhu
full_text: false
words: 258
quotes:
  - text: "there is already a very simple method in the standard codeunit 47 StringConversionManagement that can do this: GetPaddedString()."
    why_it_matters: Identifies the built-in method developers should use instead of writing custom padding logic
  - text: If the original string is already longer than PadLength, GetPaddedString() does not truncate the string.
    why_it_matters: "Clarifies important behavior: the method preserves longer strings without cutting them"
code_objects_mentioned:
  - codeunit StringConversionManagement
systems:
  - development
versions_mentioned: []
cautions:
  - kind: gotcha
    quote: If the original string is already longer than PadLength, GetPaddedString() does not truncate the string.
    objects:
      - type: codeunit
        name: StringConversionManagement
    events: []
    versions: []
preview:
  embeddable: true
  frame_url: null
  image: https://yzhums.com/wp-content/uploads/2026/11/Snipaste_2026-11-26_13-12-54.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-11-27T00:55:35.853Z"
---

# Dynamics 365 Business Central: How to pad a string to a specified length with a character (GetPaddedString)

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

> GetPaddedString is a method in Business Central's StringConversionManagement codeunit that fills a string with a specified character until it reaches a desired length, supporting both left and right justification.

## Key points

- GetPaddedString pads strings by adding a character to reach a target length
- Left justification adds padding characters to the right, right justification adds them to the left
- If the original string exceeds the pad length, it is not truncated
- The method is built into standard codeunit 47 StringConversionManagement

## Quotes

- "there is already a very simple method in the standard codeunit 47 StringConversionManagement that can do this: GetPaddedString()." (Identifies the built-in method developers should use instead of writing custom padding logic)
- "If the original string is already longer than PadLength, GetPaddedString() does not truncate the string." (Clarifies important behavior: the method preserves longer strings without cutting them)

## 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.

- [codeunit 47 "StringConversionManagement"](../../objects/codeunit/47.md)

## Possibly related

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

- [Dynamics 365 Business Central: How to quickly remove Non-Alphanumeric Characters in AL](../../posts/yzhums-com/75649.md) — possibly related: both name Codeunit 47 "StringConversionManagement"
- [Understanding AL Development: String Conversion Management Code Unit](../../posts/aardvarklabs-blog/2741.md) — possibly related: both name Codeunit 47 "StringConversionManagement"

## Heads up

- gotcha: "If the original string is already longer than PadLength, GetPaddedString() does not truncate the string." (about codeunit StringConversionManagement)

## Context

- Features: GetPaddedString, string padding, character fill, left justification, right justification

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.
