# Switch Node Sequence Rules

**URL:** <https://discourse.nodered.org/t/switch-node-sequence-rules/30405>\
**Category:** General\
**Created:** [20 July 2020 13:59 UTC](https://discourse.nodered.org/t/switch-node-sequence-rules/30405 "2020-07-20T13:59:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![n61ab](https://avatars.discourse-cdn.com/v4/letter/n/cc9497/32.png) [@n61ab](https://discourse.nodered.org/u/n61ab)\
**Post date:** [20 July 2020 13:59 UTC](https://discourse.nodered.org/t/switch-node-sequence-rules/30405/1 "2020-07-20T13:59:05Z")

</div>

I have imported a flow that uses the Switch Node in a way I want to understand what it does.

I am looking for information on how to use the "Sequence Rules" in the Switch Node. More specifically the "Index Between" rule.

Searching the forum and google has not found an information source on this rule.

Can anyone point me to an information source?

Alan

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [20 July 2020 16:17 UTC](https://discourse.nodered.org/t/switch-node-sequence-rules/30405/2 "2020-07-20T16:17:27Z")

</div>

If you have previously used a split node to split up a message into parts (each of which then has an index) - this rule can be used to switch the messages based on that specified index.

---

<div class="post-metadata">

**Author:** ![n61ab](https://avatars.discourse-cdn.com/v4/letter/n/cc9497/32.png) [@n61ab](https://discourse.nodered.org/u/n61ab)\
**Post date:** [20 July 2020 17:16 UTC](https://discourse.nodered.org/t/switch-node-sequence-rules/30405/3 "2020-07-20T17:16:59Z")

</div>

Thanks dceejay. Got it. Alan

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [20 July 2020 17:28 UTC](https://discourse.nodered.org/t/switch-node-sequence-rules/30405/4 "2020-07-20T17:28:14Z")

</div>

From the node help

> 1. **Sequence** rules can be used on message sequences, such as those generated by the Split node

(@dceejay please correct me if I'm wrong),

- Sequence Rules are based on msg.parts.count and msg.parts.index - if either of them are missing from the msg, those rules will not do anything.
- The `Property` option plays no part in the Sequence rules. You can leave that option blank and while it will produce a warning that the node is not properly configured, it will still work
- HEAD - will return the first thru Nth msgs where N is the value in the head option.
- INDEX BETWEEN will return the msgs in the sequence `based on msg.index` - remember the first msg is index 0, the second msg is index 1, etc), between the two values specified
- TAIL - will return the Nth last msgs in the sequence where N is the value in the tail option. If you set 'Tail' to 1, it will return the lsat msg in the sequence. If you set it to 3, it will return the last three msgs in the sequence.

NOTE: It is possible - with 'check all rules' selected, to get multiple copies of the same message depending on your settings. For example, say you start with a msg.payload of 'this is a test' and you set 'Head' to 1, 'Index between' to 1 and 2 and 'Tail' to 2, you will get 'this', 'is', 'a', 'a', 'test'

---

<div class="post-metadata">

**Author:** ![n61ab](https://avatars.discourse-cdn.com/v4/letter/n/cc9497/32.png) [@n61ab](https://discourse.nodered.org/u/n61ab)\
**Post date:** [20 July 2020 19:16 UTC](https://discourse.nodered.org/t/switch-node-sequence-rules/30405/5 "2020-07-20T19:16:02Z")

</div>

Thanks zenofmud. Great explanation. Alan

---

<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:** [18 September 2020 19:16 UTC](https://discourse.nodered.org/t/switch-node-sequence-rules/30405/6 "2020-09-18T19:16:12Z")

</div>

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