# Trying to Switch on payload.settings.id

**URL:** <https://discourse.nodered.org/t/trying-to-switch-on-payload-settings-id/56668>\
**Category:** General\
**Created:** [14 January 2022 17:42 UTC](https://discourse.nodered.org/t/trying-to-switch-on-payload-settings-id/56668 "2022-01-14T17:42:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gcortes](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gcortes/32/37823_2.png) [@gcortes](https://discourse.nodered.org/u/gcortes)\
**Post date:** [14 January 2022 17:42 UTC](https://discourse.nodered.org/t/trying-to-switch-on-payload-settings-id/56668/1 "2022-01-14T17:42:13Z")

</div>

I'm trying set up a switch node to switch on the payload.settings.id without success. Here's the message from debug:

```auto
object
action: "org.tynsoe.streamdeck.wsproxy.proxy-ms"
context: "96DB827800309F7A70FA1BAFEE533B50"
device: "8FF7DE8B17F078F2BD537F99F7BC56F6"
event: "keyUp"
payload: object
  coordinates: object
  isInMultiAction: false
  settings: object
    id: "buttonblue"
    remoteServer: "ws://10.0.0.185:1880/ws/streamdeck"
  state: 1

```

In node-red, I hovered over the id field and selected the copy path option. I then pasted it into the Property field of the switch node. The drop down selection is set to "msg.". The paste inserted "payload.payload.settings.id".  
The test is == and the value is buttonblue

The output of the node is to a debug node. I never see any output from that node. I've also tried "payload.settings.id", "settings.id", and just "id. None work.

I have another switch statement that tests a different field ("event"). It works fine. The switch test is down stream from "websocket in" and "sd input". The latter handles input from a Streamdeck. I couldn't find any examples on the web for the specific field. I'm sure it's a stupid user error.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [14 January 2022 17:48 UTC](https://discourse.nodered.org/t/trying-to-switch-on-payload-settings-id/56668/2 "2022-01-14T17:48:02Z")

</div>

> [@gcortes](#):
>
> The test is == and the value is buttonblue

Did you have "a/z" string mode?

Did you add quotes? (They are not needed)

Are you certain there is no additional whitespace or non printing characters in the string (e.g. a newline or carriage return)

Show us a screen shot of the debug & a screenshot of the switch node.

Ps, when copying the payload value, use the "copy value" button.

---

<div class="post-metadata">

**Author:** ![gcortes](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gcortes/32/37823_2.png) [@gcortes](https://discourse.nodered.org/u/gcortes)\
**Post date:** [14 January 2022 17:54 UTC](https://discourse.nodered.org/t/trying-to-switch-on-payload-settings-id/56668/3 "2022-01-14T17:54:02Z")

</div>

I used az, I didn't use quotes, and there is no white space.

The switch node:

 ![Screen Shot 2022-01-14 at 09.51.19](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/a/cae8a6c1f81151edcd73ceafe9aac86fd7f80254.png)

The debug output:

 ![Screen Shot 2022-01-14 at 09.52.52](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/b/2bde6d8f482a9f1f94ba5b77a1d176b1960ea747.png)

I added a new switch statement to test the state. The link was set to payload.payload.state. It works.

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [14 January 2022 20:32 UTC](https://discourse.nodered.org/t/trying-to-switch-on-payload-settings-id/56668/4 "2022-01-14T20:32:15Z")

</div>

Try Property: `msg.payload.settings.id` rather than `msg.payload.payload.settings.id`

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [14 January 2022 21:40 UTC](https://discourse.nodered.org/t/trying-to-switch-on-payload-settings-id/56668/5 "2022-01-14T21:40:49Z")

</div>

The debug out certainly seems to show that your path is correct (with the double payload fields).

So if you are not seeing any output from the downstream `debug` node, I have to ask -- is the tab on the side pushed in (deactivated) or pulled out (active)? Which, if any, of the 3 output checkboxes (debug window, console, and node status) are checked? Is the source end of the wire connected to the `switch` port 1, or might the wire be routed "behind" the switch node (very unlikely)?

Assuming all of those are set correctly, the only other thing I can think of is that an exception is occurring -- but you would see that in the debug sidebar instead. Maybe try a `catch` node?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [14 January 2022 21:43 UTC](https://discourse.nodered.org/t/trying-to-switch-on-payload-settings-id/56668/6 "2022-01-14T21:43:40Z")

</div>

~~Ok, I'll ask the $100 question.~~

~~Why `msg.payload.payload`?~~

I need to read a bit more on the picture. Sorry.

---

<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:** [14 January 2022 21:45 UTC](https://discourse.nodered.org/t/trying-to-switch-on-payload-settings-id/56668/7 "2022-01-14T21:45:51Z")

</div>

Looking at the debug output it certainly looks like it should be `msg.payload.payload.settings.id`  
Configure the Switch with an Otherwise output, connect two (named) debug nodes to the outputs and show us what you see. If it sends it to the wrong output then possibly there are unprintable characters in the string. Feed it into a Function node containing  
`node.warn(`id length: ${msg.payload.payload.settings.id.length}`) `return msg`  
and see what you get in the debug pane.

---

<div class="post-metadata">

**Author:** ![gcortes](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gcortes/32/37823_2.png) [@gcortes](https://discourse.nodered.org/u/gcortes)\
**Post date:** [14 January 2022 22:16 UTC](https://discourse.nodered.org/t/trying-to-switch-on-payload-settings-id/56668/8 "2022-01-14T22:16:49Z")

</div>

Now it works. I'm pretty sure @shrickus had it right about the debug node being deactivated. I cut and pasted the debug node and must not have noticed it was deactivated. So, yes, it was a stupid user error. My apologies for wasting your time.

---

<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:** [28 January 2022 22:16 UTC](https://discourse.nodered.org/t/trying-to-switch-on-payload-settings-id/56668/9 "2022-01-28T22:16:54Z")

</div>

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