# Set new values with conditions

**URL:** <https://community.n8n.io/t/set-new-values-with-conditions/21158>\
**Category:** Questions\
**Tags:** code\
**Created:** [December 26, 2022, 8:19pm UTC](https://community.n8n.io/t/set-new-values-with-conditions/21158 "2022-12-26T20:19:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Philippe](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/philippe/32/20752_2.png) [@Philippe](https://community.n8n.io/u/Philippe)\
**Post date:** [December 26, 2022, 8:19pm UTC](https://community.n8n.io/t/set-new-values-with-conditions/21158/1 "2022-12-26T20:19:57Z")

</div>

Hello,

I need a bit of help here.

I have a node with Priorities in numbers I want to convert in Low, Medium and High.

Example:  
Priority: ‘1’ convert to ‘Low’  
Priority: ‘2’ convert to ‘Medium’  
Priority: ‘3’ convert to ‘High’

I know I need to do a combination of code functions, but it does not work:

Many thanks in advance

Philippe

---

<div class="post-metadata">

**Author:** ![Dtneo](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/dtneo/32/140423_2.png) [@Dtneo](https://community.n8n.io/u/Dtneo)\
**Post date:** [December 26, 2022, 8:23pm UTC](https://community.n8n.io/t/set-new-values-with-conditions/21158/2 "2022-12-26T20:23:53Z")

</div>

Hello, the node “switch” exist and can do that (I think)

---

<div class="post-metadata">

**Author:** ![Philippe](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/philippe/32/20752_2.png) [@Philippe](https://community.n8n.io/u/Philippe)\
**Post date:** [December 26, 2022, 10:47pm UTC](https://community.n8n.io/t/set-new-values-with-conditions/21158/3 "2022-12-26T22:47:22Z")

</div>

Yes, but I do not need to create 4 different routes… I will only have 1 result per priority  
If I have “Priority” :2 then “Priority”:“Medium”

Thanks anyway for your time!

---

<div class="post-metadata">

**Author:** ![Dtneo](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/dtneo/32/140423_2.png) [@Dtneo](https://community.n8n.io/u/Dtneo)\
**Post date:** [December 27, 2022, 10:39pm UTC](https://community.n8n.io/t/set-new-values-with-conditions/21158/4 "2022-12-27T22:39:21Z")

</div>



---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [December 28, 2022, 4:01pm UTC](https://community.n8n.io/t/set-new-values-with-conditions/21158/5 "2022-12-28T16:01:52Z")

</div>

Hi @Philippe, if you don’t want to go down the Switch node route suggested by @Dtneo, you could use code as well but it shouldn’t be necessary.

Here’s how it would look like using the [switch](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch) approach from your workflow:

What I’ve done here was switching to the “Run Once for Each Item” mode, then replacing the `item` keyword from your example with `$input.item.json` as suggested in the example code used by the new Code node:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/9/1/9184982324cc9b369f60af36060bf6fe4c756d10.png)

This is the result:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/c/f/cf79677f75d6a74bb8cf8aff79e2bec913a61354.png)

Hope this helps!

---

<div class="post-metadata">

**Author:** ![Philippe](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/philippe/32/20752_2.png) [@Philippe](https://community.n8n.io/u/Philippe)\
**Post date:** [December 29, 2022, 8:53pm UTC](https://community.n8n.io/t/set-new-values-with-conditions/21158/6 "2022-12-29T20:53:39Z")

</div>

Good evening @MutedJam,

Thanks for your answer I just see now. I finally managed by using a “ApplyMap” Node made by @BramKn.

I will look at the node you proposed anyway.

Many thanks

Philippe

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/36532_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [January 5, 2023, 8:54pm UTC](https://community.n8n.io/t/set-new-values-with-conditions/21158/7 "2023-01-05T20:54:10Z")

</div>

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