# Pin pointing error in fucntion script

**URL:** <https://discourse.nodered.org/t/pin-pointing-error-in-fucntion-script/99892>\
**Category:** General\
**Created:** [8 December 2025 11:56 UTC](https://discourse.nodered.org/t/pin-pointing-error-in-fucntion-script/99892 "2025-12-08T11:56:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jimbo84](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@Jimbo84](https://discourse.nodered.org/u/Jimbo84)\
**Post date:** [8 December 2025 11:56 UTC](https://discourse.nodered.org/t/pin-pointing-error-in-fucntion-script/99892/1 "2025-12-08T11:56:39Z")

</div>

I'm getting an error on a function script but I'm not really sure where in the code. Below is the error, does it tell me a line number or anything as there's lot of numbers here so not sure which it is

```auto
TypeError: Cannot read properties of undefined (reading 'substring')
    at Function node:8b6c7c7b38a2dcf0 [Build CXML]:8:27
    at Function node:8b6c7c7b38a2dcf0 [Build CXML]:215:3
    at Script.runInContext (node:vm:149:12)
    at processMessage (/usr/src/node-red/node_modules/@node-red/nodes/core/function/10-function.js:430:37)
    at FunctionNode._inputCallback (/usr/src/node-red/node_modules/@node-red/nodes/core/function/10-function.js:348:17)
    at /usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:214:26
    at Object.trigger (/usr/src/node-red/node_modules/@node-red/util/lib/hooks.js:166:13)
    at Node._emitInput (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:206:11)
    at Node.emit (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:190:25)

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 December 2025 12:13 UTC](https://discourse.nodered.org/t/pin-pointing-error-in-fucntion-script/99892/2 "2025-12-08T12:13:59Z")

</div>

> [@Jimbo84](#):
>
> `TypeError: Cannot read properties of undefined (reading 'substring')`

That means you have tried to call substring() but the thing you are calling it on is undefined. So for example you might have `msg.payload.substring(..)` but msg.payload does not exist. Look for all uses of substring in the function and hopefully it will give you a clue.

---

<div class="post-metadata">

**Author:** ![Jimbo84](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@Jimbo84](https://discourse.nodered.org/u/Jimbo84)\
**Post date:** [8 December 2025 12:44 UTC](https://discourse.nodered.org/t/pin-pointing-error-in-fucntion-script/99892/3 "2025-12-08T12:44:08Z")

</div>

Hi Colin, I get that but does the error give me a clue which line it's on as there are a few substring in the code

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [8 December 2025 13:03 UTC](https://discourse.nodered.org/t/pin-pointing-error-in-fucntion-script/99892/4 "2025-12-08T13:03:33Z")

</div>

> [@Jimbo84](#):
>
> ```auto
> TypeError: Cannot read properties of undefined (reading 'substring')
> at Function node:8b6c7c7b38a2dcf0 [Build CXML]:8:27
> 
> ```

What does the function have around line 8 (perhaps line 7)?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [8 March 2026 13:03 UTC](https://discourse.nodered.org/t/pin-pointing-error-in-fucntion-script/99892/5 "2026-03-08T13:03:42Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
