# \[Solved\] How to use switch block?

**URL:** <https://forums.losant.com/t/solved-how-to-use-switch-block/486>\
**Category:** Help\
**Created:** [May 9, 2017, 4:33am UTC](https://forums.losant.com/t/solved-how-to-use-switch-block/486 "2017-05-09T04:33:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim\_lamborn](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@Tim\_lamborn](https://forums.losant.com/u/Tim_lamborn)\
**Post date:** [May 9, 2017, 4:33am UTC](https://forums.losant.com/t/solved-how-to-use-switch-block/486/1 "2017-05-09T04:33:09Z")

</div>

Hi,

My device has a tag called “Type”. How can I use that in a switch block? I tried

{{data.myDevice.tags.Type}}

with no luck. Note that myDevice is populated correctly by a Get Device block. It contains my tags in an array, I can see them in the debug window but I don’t know how to use them in a switch block! I always get default case.

I also want to use one character in my payload in another switch block but I don’t know how to access that either! e.g. if my data.body.data = “1114”, I want to switch on the first character “1”. How can I do this?

Thanks

Ashley

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [May 9, 2017, 7:19pm UTC](https://forums.losant.com/t/solved-how-to-use-switch-block/486/2 "2017-05-09T19:19:39Z")

</div>

For the tag lookup, check out the `valueByKey` [format helper](https://docs.losant.com/workflows/accessing-payload-data/#format-helpers). Assuming your device is stored on your payload at `data.myDevice`, and you have not mutated the result to remove the tags, you would look up the value of the `Type` tag with the helper:

```auto
{{valueByKey data.myDevice.tags 'Type'}}

```

For isolating the first character of a string that is stored on the payloada at `data.body.data`, use this helper:

```auto
{{data.body.data.[0]}}

```

The `0` represents the character at position 0 (the first position); if you wanted to get the second character, you would switch the `0` to a `1` and so on.

We have some [pretty detailed documentation](https://docs.losant.com/workflows/accessing-payload-data/) on using helpers and payload paths to access data in your workflows. If anything is unclear here, please let us know so we can improve the docs!

---

<div class="post-metadata">

**Author:** ![Tim\_lamborn](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@Tim\_lamborn](https://forums.losant.com/u/Tim_lamborn)\
**Post date:** [May 9, 2017, 10:35pm UTC](https://forums.losant.com/t/solved-how-to-use-switch-block/486/3 "2017-05-09T22:35:18Z")

</div>

Great, thanks for the help, I will give it a go. I never would have thought to put .[0] instead of just [0]!

Regards

Ashley
