Switch case, conditions

Hello!
No description
3 Replies
gxOTERROR
gxOTERROROP2w ago
i trying to make this easy fluxogram but how i can verify the Error variable?
switch ({{FirstSelectMenu}}) {
case 1:
return "Você escolheu a opção 1";
case 2:
return "Você escolheu a opção 2";
case 3:
return "Você escolheu a opção 3";
case 4:
return "Você escolheu a opção 4";
case 5:
return "Você escolheu a opção 5";
default:

return "404";
}
switch ({{FirstSelectMenu}}) {
case 1:
return "Você escolheu a opção 1";
case 2:
return "Você escolheu a opção 2";
case 3:
return "Você escolheu a opção 3";
case 4:
return "Você escolheu a opção 4";
case 5:
return "Você escolheu a opção 5";
default:

return "404";
}
i need to created a loop if no received correct number
Baptiste
Baptiste5d ago
What's the question?
Anthony
Anthony4d ago
Some things I see you could do better: - There's no point in using the setVariable() function inside the Set variable block. Anything you put as the value of the block will already be the value of the variable you're defining. So just put "0" in the Set variable block. Though, you're defining ErrorFirstSelectMenu as 0 but never using it in your flow, so I'm wondering why it exists in the first place 🤔 - Now I see you're using a switch condition when it's definitely not needed. Why? Because you basically only are appending the user-inputted number to a fixed string Você escolheu a opção if the number is between 1 and 5, otherwise you want to do something else. Another thing that proves that you don't even have to do this is that you can set a "Min" and "Max" value in the Number Input block, meaning that your users could not even input a number value that is outside of that range. So I'd advise you just put 1 as the Min and 5 as the Max, so you won't even have to have a complex "Error" check. In the image below, I made your flow a 3-block flow with no conditional check needed, and using inline code to append the user-inputted number to Você escolheu a opção . Put this code inside a regular Text Bubble:
{{= "Você escolheu a opção " + {{number}} =}}
{{= "Você escolheu a opção " + {{number}} =}}
Hope it helps!
No description
No description

Did you find this page helpful?