---
schema_version: "1"
id: 1a6e02ff990803a222b68f34dcf54beaff76c184318c88d0dc9eb1a66a903301
title: appendIfMissing
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.6/dw-strings-functions-appendifmissing.md
canonical_url: https://docs.mulesoft.com/dataweave/2.6/dw-strings-functions-appendifmissing
source_site: docs.mulesoft.com
content_type: documentation
content_hash: d9935c60333de5f82fc30666ed11222849af4d589822c4232e7f548eced504a8
description: MuleSoft Documentation Site
release: "2.6"
latest: false
---
---
product: DataWeave
version: 2.6
---

# appendIfMissing

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## appendIfMissing(text: String, suffix: String): String

Appends the `suffix` to the end of the `text` if the `text` does not already ends with the `suffix`.

_Introduced in DataWeave version 2.2.0._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>text</code></p></td><td><p>The input string.</p></td></tr><tr><td><p><code>suffix</code></p></td><td><p>The text used as the suffix.</p></td></tr></tbody></table>

### Example

This example shows how `appendIfMissing` behaves with different inputs and sizes.

#### Source

```DataWeave
%dw 2.0
import appendIfMissing from dw::core::Strings
output application/json
---
{
  "a": appendIfMissing(null, ""),
  "b": appendIfMissing("abc", ""),
  "c": appendIfMissing("", "xyz") ,
  "d": appendIfMissing("abc", "xyz") ,
  "e": appendIfMissing("abcxyz", "xyz")
}
```

#### Output

```JSON
{
  "a": null,
  "b": "abc",
  "c": "xyz",
  "d": "abcxyz",
  "e": "abcxyz"
}
```

## appendIfMissing(text: Null, suffix: String): Null

Helper function that enables `appendIfMissing` to work with a `null` value.

_Introduced in DataWeave version 2.2.0._
