# TypeError: msg.parts.index is not a function

**URL:** https://discourse.nodered.org/t/typeerror-msg-parts-index-is-not-a-function/58258
**Category:** General
**Tags:** function-node
**Created:** [13 February 2022 12:57 UTC](https://discourse.nodered.org/t/typeerror-msg-parts-index-is-not-a-function/58258 "2022-02-13T12:57:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![fmejialo](https://avatars.discourse-cdn.com/v4/letter/f/d9b06d/32.png) [@fmejialo](https://discourse.nodered.org/u/fmejialo)
#### Post date: [13 February 2022 12:57 UTC](https://discourse.nodered.org/t/typeerror-msg-parts-index-is-not-a-function/58258/1 "2022-02-13T12:57:06Z")

</div>

Hi, I'm trying to create a function that receives a split message, converts the message into variables and looks at a condition of the message to perform an action, but I always get a syntax error and I don't understand why, can someone help me correct this, thank you. here I leave the code.

```auto
var id = global.get("serial");

var s = msg.parts.index(0);
var f = msg.parts.index(1);
var e = msg.parts.index(2);

if (s == id) {
    msg.payload = + f + e;
    return msg;
}
else {
        msg.payload = null;
    }

```

Tanks...

---

<div class="post-metadata">

### Author: ![mickym2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mickym2/32/36128_2.png) [@mickym2](https://discourse.nodered.org/u/mickym2)
#### Post date: [13 February 2022 13:12 UTC](https://discourse.nodered.org/t/typeerror-msg-parts-index-is-not-a-function/58258/2 "2022-02-13T13:12:35Z")

</div>

What should the brackets after index. In index there is a number. It is not an array or object - and then you need brackets. Your syntax is completely wrong.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/5/556a0abeb0edef862335d54fdf9adec7d090c488.png)

In addition you cannot use f and e - as it can never happen - that a msg with diffferen parts.index values will reach your function. In this case - I think it makes no sense to use a split node anyway.

---

<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: [14 April 2022 13:13 UTC](https://discourse.nodered.org/t/typeerror-msg-parts-index-is-not-a-function/58258/3 "2022-04-14T13:13:09Z")

</div>

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