---
title: "SDK: Text Merge Extensions"
slug: "text-merge-extensions"
description: "This document shows how to create custom text merge logic by making a Text Merge Extension in the Decisions SDK. The included example demonstrates how to write a Text Merge Extension that returns the length of a string. "
updated: 2024-08-20T14:57:44Z
published: 2024-08-20T14:57:44Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.decisions.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SDK: Text Merge Extensions

## Overview

Decisions includes a number of built-in text merge fields like "Capitalize," "Lower," and "Insert Current Date." These merge fields can be used to dynamically manipulate strings or insert data from other sources into a Text Merge. Text merge extensions allow a user to write custom text merge logic to accomplish any type of merge desired.

## Example

This example will demonstrate how to create a text merge that returns the length of a string.

1. Download the **Decisions SDK** from **Manage** **NuGet Packages**and add the following using statements**:**  

```csharp
using DecisionsFramework.Design.Text;
using DecisionsFramework.ServiceLayer.Services.ContextData;
using DecisionsFramework.Utilities.Data;
```
2. Have the class inherit from and implement AbstractStringFieldExtension.

When implementing this class, it includes two override methods: string **GetMergeText** and string Name.

The string returned by GetMergeText will be the string displayed at the run time of your Text Merge. The string returned by **Name** will be the name of the merge displayed at design time.

Below is an example implementation of string Name which will return the name of **Get String Length.**

```csharp
public override string Name => "Get String Length";
```

This name of Get String Length will show in the Designer as shown below:

![](https://cdn.document360.io/6ef8bcc1-6489-4486-9ad1-83acff7e5df0/Images/Documentation/2024-07-09_15h29_49.png)![](https://cdn.document360.io/6ef8bcc1-6489-4486-9ad1-83acff7e5df0/Images/Documentation/2024-07-09_15h31_00.png)![](https://cdn.document360.io/6ef8bcc1-6489-4486-9ad1-83acff7e5df0/Images/Documentation/2024-07-09_15h32_47.png)

Below is an example implementation of the string GetMergeText method which will return the length of the string.

```csharp
public override string GetMergeText(DataPair[] data)
{
   string text = null;

   object value;
   if (DataUtilities.TryGetValue(data, TextField, out value))
   {
       text = Convert.ToString(value);
       return text.Length.ToString();
   }
   else
   {
       return null;
   }
}
```

Using this new Get String Length merge, the string's length will be returned as shown below:

![](https://cdn.document360.io/6ef8bcc1-6489-4486-9ad1-83acff7e5df0/Images/Documentation/2024-08-20_10h57_26.png)
