# Condition on enum value not working as expected

**URL:** <https://community.appfarm.io/t/condition-on-enum-value-not-working-as-expected/549>\
**Category:** Ask the community\
**Created:** [June 27, 2023, 1:50pm UTC](https://community.appfarm.io/t/condition-on-enum-value-not-working-as-expected/549 "2023-06-27T13:50:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Preben](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/preben/32/545_2.png) [@Preben](https://community.appfarm.io/u/Preben)\
**Post date:** [June 27, 2023, 1:50pm UTC](https://community.appfarm.io/t/condition-on-enum-value-not-working-as-expected/549/1 "2023-06-27T13:50:26Z")

</div>

Hi,

I’m trying to use a very straight forward condition on an runtime only object’s enum value.

The UI is a repetable container showing the enum value invoice status. But when trying to set a condition to the enum value, e.g. invoice status = “betalt” then the condition only return false

Condition

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/1X/d37092fbfbfd77e58ef3c56bb6cdb93839833d3f.png)

data:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/1X/5b18c85e38cb6b644ab8a00bcf20d7b11f484389.png)

---

<div class="post-metadata">

**Author:** ![Eirik](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/eirik/32/76_2.png) [@Eirik](https://community.appfarm.io/u/Eirik)\
**Post date:** [June 28, 2023, 5:48am UTC](https://community.appfarm.io/t/condition-on-enum-value-not-working-as-expected/549/2 "2023-06-28T05:48:14Z")

</div>

Hi Preben,

Could you share some more details on how your UI is set up? Where are you using this condition and what is the context of `Invoice (temp)` where this condition is used?

---

<div class="post-metadata">

**Author:** ![Preben](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/preben/32/545_2.png) [@Preben](https://community.appfarm.io/u/Preben)\
**Post date:** [June 28, 2023, 5:58am UTC](https://community.appfarm.io/t/condition-on-enum-value-not-working-as-expected/549/3 "2023-06-28T05:58:37Z")

</div>

I’m planning to use it on a conditional style on a container, changing the color of the background based on the status.

Invoice (temp) is a list of invoices created from a web request where I use a function to set the invoice status on each line.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/1X/41340d17d95903bdc76ca625ea82bb80d03e59d5.png)

It could have something to do with the way I set the enum value on the records, but in the devtool it looks correct  
Function to set enum values

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/1X/7062f9253cd38f58d8a2dc139191cbbc89b465ad.png)

---

<div class="post-metadata">

**Author:** ![Eirik](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/eirik/32/76_2.png) [@Eirik](https://community.appfarm.io/u/Eirik)\
**Post date:** [June 28, 2023, 6:03am UTC](https://community.appfarm.io/t/condition-on-enum-value-not-working-as-expected/549/4 "2023-06-28T06:03:20Z")

</div>

I believe you would have to return the `betalt.value` in your switch if that’s the enum value.

When adding an enum value as a function property is comes as a key-value pair (unless you add the value part of the enum directly. I don’t know if you have done that and renamed it).

Could you verify if the betalt/delbetalt/ubetalt are key-value pairs, and if so that it works if you add the `.value` part in your return statements?

---

<div class="post-metadata">

**Author:** ![Preben](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/preben/32/545_2.png) [@Preben](https://community.appfarm.io/u/Preben)\
**Post date:** [June 28, 2023, 6:26am UTC](https://community.appfarm.io/t/condition-on-enum-value-not-working-as-expected/549/5 "2023-06-28T06:26:28Z")

</div>

Thanks. That was the missing piece 🙂
