# How to do an if with "function"

**URL:** https://discourse.nodered.org/t/how-to-do-an-if-with-function/62728
**Category:** General
**Created:** [17 May 2022 07:15 UTC](https://discourse.nodered.org/t/how-to-do-an-if-with-function/62728 "2022-05-17T07:15:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![joonaskng](https://avatars.discourse-cdn.com/v4/letter/j/8dc957/32.png) [@joonaskng](https://discourse.nodered.org/u/joonaskng)
#### Post date: [17 May 2022 07:15 UTC](https://discourse.nodered.org/t/how-to-do-an-if-with-function/62728/1 "2022-05-17T07:15:20Z")

</div>

Hello, my Output is "S7CpuStatusRun" and i want to make an if or something, that is changing the "S7CpuStatusRun" to just "Run" but i dont know how to do that because i have no idea how an if should work like this or what i could use instead of an if

I really hope someone knows the answer, that would really help me

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [17 May 2022 07:31 UTC](https://discourse.nodered.org/t/how-to-do-an-if-with-function/62728/2 "2022-05-17T07:31:24Z")

</div>

Use a change node. See the documentation: [working with messages](https://nodered.org/docs/user-guide/messages)

You probably want to use a switch node as well to "test" if the received message is 'S7CpuStatusRun' and then use the change node.

---

<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: [16 July 2022 07:31 UTC](https://discourse.nodered.org/t/how-to-do-an-if-with-function/62728/3 "2022-07-16T07:31:25Z")

</div>

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