How do I convert a specific string value to true / false?

Hey!
How do I convert a specific string value to true / false and apply to a Boolean object in a set node?


Hi @Roket

I made a simple workflow based on my understanding. Not sure this is right or wrong.

image

mcnaveen, thanks for the answer!
This is not what I want (.
I’ll try to explain in words.

  1. I have a webhook with a payload that contains multiple strings with a “Y” or “N” value.
  2. Next, I have a set node, in which I want to convert this value to true or false, respectively, but changing the type of the object (if I correctly interpret the terminology, perhaps this is a misunderstanding of my task) from string to boolean.
  3. The expression I need to write inside the boolean field, which is located in the set node.

    I tried for a few hours to figure out the javascript here: Conditional (ternary) operator - JavaScript | MDN
    But nothing happened, unfortunately (.

Hey @Roket, since you are using the assignment operator = instead of the comparison operator in JavaScript ===, the is_need_corrector variable always gets the value Y assigned and it will always return true. Since you want conversion to boolean values here, you don’t really need to use the conditional operator as the comparison operator returns boolean values. More details here.

Here’s an example workflow:

Hope that helps :slight_smile:

2 Likes

tanay, Thanks!
Its works!)

1 Like

That’s great to hear, have fun! :slight_smile:

1 Like