---
title: "substring Formula Function: Extract Part of a Text in Nodinite Search Fields"
description: The substring Formula function returns part of a text from a zero-based start index and a length, from the message body, a context property, or another function such as jsonPath.
---

# :fa-function: Formula - substring

The `substring` [Formula][] function returns `length` characters of the content, starting at the zero-based `startIndex`.

![Keep only the date of an order with substring around jsonPath, animated walkthrough (7.12)][1]  
*Animated walkthrough: on the Order Received JSON of the [Order-to-Cash demo][], `jsonPath('$.orderDate', body)` returns the order date and time. Wrapped in `substring(0, 10, …)`, ten characters from the first one remain: the date only, such as `2026-11-15`.*  

## :fa-code: Syntax

```text
substring(startIndex, length, content)
```

### Parameters

|Parameter|Required|Description|
|---|---|---|
|`startIndex`|Yes|The zero-based position of the first character to return; `0` is the first character. Write it as a number, without quotes.|
|`length`|Yes|The number of characters to return. Write it as a number, without quotes.|
|`content`|Yes|The text to take characters from: [body][], [context][], or the result of another function, such as [jsonPath][].|

### Returns

The part of the content from `startIndex` for `length` characters. When the content holds several values, each value is cut and returned as its own [Search Field][What is a Search Field] value.

## :fa-list-ol: Examples

### Example 1: Take the first four characters of the message body

#### Input

```text
nodinte
```

#### Formula

```text
substring(0, 4, body)
```

#### Result

```text
nodi
```

![Test Expression tab: substring(0, 4, body) returns nodi][15]  
*Start index `0` is the first character, so four characters from the start are returned.*  

### Example 2: Take the first word of a context property

#### Input

|Key|Value|
|---|---|
|`id`|`Amazing Function`|

#### Formula

```text
substring(0, 7, context('id'))
```

#### Result

```text
Amazing
```

![Test Expression tab: substring(0, 7, context('id')) returns Amazing for the context value Amazing Function][17]  
*Seven characters from the start of the context value `Amazing Function`.*  

### Example 3: Take the first two characters of several jsonPath values

#### Input

```json
[
{ "name": "column" },
{ "name": "olive"}
]
```

#### Formula

```text
substring(0, 2, jsonPath('$..name', body))
```

#### Result

```text
co
ol
```

![Test Expression tab: substring on two jsonPath values returns co and ol][16]  
*`jsonPath` returns two values, and `substring` cuts each one: two unique matches.*  

## :fa-circle-info: Notes

* A `startIndex` past the end of the text gives no value: `substring(10, 4, body)` on `nodinte` shows the warning *The Expression yields no result*.
* A `length` that runs past the end returns the rest of the text, without an error: `substring(4, 10, body)` on `nodinte` returns `nte`.

## :fa-hand-point-right: Next Steps

* :fa-magnifying-glass-plus: [Add or manage Search Field][]  
* :fa-flask: [Test Your Expression][]  
* :fa-hard-drive: [Add or manage Log View][]  

## :fa-link-horizontal: Related Topics

* :fa-link: [concat][]  
* :fa-eraser: [removebom][]  
* :fa-right-left: [replace][]  
* :fa-code: [replaceregex][]  
* :fa-function: [Formula][]  
* :fa-scroll: [Formula language rules][]  
* :fa-puzzle-piece: [Search Field Expressions][]  

[1]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Alter/Formula_Substring.gif
[15]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Alter/substring_simplecontent.png
[16]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Alter/substring_nestedContent.png
[17]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Alter/substring_simpleContent_messageContext.png

[Add or manage Log View]:{ndr}/Administration/1.%20Log%20Management/1.%20Log%20Views/Features/Add%20or%20Manage%20Log%20View.md
[Add or manage Search Field]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Add%20or%20manage%20Search%20Field.md
[body]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Source/body.md
[concat]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Alter/concat.md
[Context]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Source/context.md
[Formula]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Overview.md
[Formula language rules]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Overview.md#fa-scroll-formula-language-rules
[jsonPath]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Extract/jsonPath.md
[Order-to-Cash demo]:{ndr}/Repository%20Model/BPMs/Examples/Order-to-Cash/Generate-O2C-Demo-Data.md
[removebom]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Alter/removebom.md
[replace]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Alter/replace.md
[replaceregex]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Alter/replaceregex.md
[Search Field Expressions]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Overview.md
[Test Your Expression]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Add%20or%20manage%20Search%20Field.md#test-your-expression
[What is a Search Field]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/What%20is%20a%20Search%20Field.md