# Logical OR within mustache expression within data

**URL:** https://discourse.nodered.org/t/logical-or-within-mustache-expression-within-data/35173
**Category:** General
**Created:** [1 November 2020 17:38 UTC](https://discourse.nodered.org/t/logical-or-within-mustache-expression-within-data/35173 "2020-11-01T17:38:19Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![cburkins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cburkins/32/30054_2.png) [@cburkins](https://discourse.nodered.org/u/cburkins)
#### Post date: [1 November 2020 17:38 UTC](https://discourse.nodered.org/t/logical-or-within-mustache-expression-within-data/35173/1 "2020-11-01T17:38:19Z")

</div>

Within the JSON portion (or "Data" field), you can obviously make use of a {{variable}} substitution. In my case, I'd like to reference msg.media\_player, unless it's not set, then default to flow.media\_player.

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

Obviously, I can add a node in front to handle that logic, but hoping to avoid the extra clutter. Most interpolation implementations offer this feature, so thinking Node-red has it ?

-Chad

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [1 November 2020 17:45 UTC](https://discourse.nodered.org/t/logical-or-within-mustache-expression-within-data/35173/2 "2020-11-01T17:45:00Z")

</div>

Call service node is a non standard HA node. So I dont have it installed. What other input options are there , does it have JSONata, or just string, number, json.

---

<div class="post-metadata">

### Author: ![cburkins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cburkins/32/30054_2.png) [@cburkins](https://discourse.nodered.org/u/cburkins)
#### Post date: [1 November 2020 17:46 UTC](https://discourse.nodered.org/t/logical-or-within-mustache-expression-within-data/35173/3 "2020-11-01T17:46:30Z")

</div>

JSON and JSONata

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [1 November 2020 17:49 UTC](https://discourse.nodered.org/t/logical-or-within-mustache-expression-within-data/35173/4 "2020-11-01T17:49:13Z")

</div>

Then use JSONata.  
when i get home i'll post an example

---

<div class="post-metadata">

### Author: ![cburkins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cburkins/32/30054_2.png) [@cburkins](https://discourse.nodered.org/u/cburkins)
#### Post date: [1 November 2020 17:55 UTC](https://discourse.nodered.org/t/logical-or-within-mustache-expression-within-data/35173/5 "2020-11-01T17:55:21Z")

</div>

That's nice of you. I'm experimenting now, might be onto something

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [1 November 2020 17:58 UTC](https://discourse.nodered.org/t/logical-or-within-mustache-expression-within-data/35173/6 "2020-11-01T17:58:38Z")

</div>

```auto
{
    "test": (payload ? payload : 1)
}

```

here a simple example.  
If msg payload exists and not null, or default 1

---

<div class="post-metadata">

### Author: ![cburkins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cburkins/32/30054_2.png) [@cburkins](https://discourse.nodered.org/u/cburkins)
#### Post date: [1 November 2020 18:13 UTC](https://discourse.nodered.org/t/logical-or-within-mustache-expression-within-data/35173/7 "2020-11-01T18:13:52Z")

</div>

Success ! Thanks for the tip.

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

---

<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: [15 November 2020 18:13 UTC](https://discourse.nodered.org/t/logical-or-within-mustache-expression-within-data/35173/8 "2020-11-15T18:13:53Z")

</div>

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