Using case statement for conditional form fields

Hi All,

I'm super new to Retool and am not a developer (as this question will likely show...), but have been working on a Form that our team will use to submit contract data that's then stored in a Retool db.

I am creating conditional fields on my form, but struggling with getting switch/case statements to work for the fields requiring more than one condition. Here is my code and the error i'm getting:

I want to be able to say, if Selection A, then display X values, if Selection B, then display Y values, else display Z values.

Any guidance on how to achieve this would be most appreciated, thank you!

Hey @DStetz!

If you're looking to write multiline JavaScript it's probably best to use a standalone transformer, write you're code there:

Then, you can reference the transformer you create in the component:

Which should give you something like this:

Does that work?

1 Like

Thank you @Kabirdas that seems to give me the missing piece I needed. Appreciate the support!