Check integer value and return text

I’m trying to check if an integer is -1 in a product table, -1 is our indication it has to be ordered.

getProdDetails.data.prodDetailQuery[0].onHand > 0 ? 'On Hand' : 'Will Be Ordered'

Returns NaN

So I’m missing something.

You’re trying to apply min (a function for numbers only) to the On Hand or Will Be Ordered strings

I’m not sure why you’re using min if accessing [0] element of the array as there should only be one value

You should be able to do something like this:

getProdDetails.data.prodDetailQuery[0].onHand == -1 ? 'Will Be Ordered' : 'On Hand'
1 Like

I updated the post, maybe it’s not showing yet. But i changed to that and it’s still returning NaN. I may mis understand how they’ve implemented ternary conditionals.

i thought was condition check, true(?) do this else ( : ) do this?

here’s the current code and still returning NaN:
getProdDetails.data.prodDetailQuery[0].onHand > 0 ? 'On Hand' : 'Will Be Ordered'

That’s correct

What is output if you just use {{getProdDetails.data.prodDetailQuery[0].onHand}} on the page?

Screen shot:
image

Never mind… maybe it didn’t save correctly or i forgot to refresh the page… it’s working all of a sudden.

1 Like

it won’t let me mark your reply as the answer :man_shrugging: