I would put the code in composition ready. There you can also write you code that will set the cases for the variable. If should work.
Yes, you can use conditionals in triggers. The first thing I would check is to confirm that your variable is actually declared somewhere. In order to debug, you can insert the following code before your trigger:
Then, when you preview your file, you can confirm whether or not the variable is actually set correctly by opening your browser's console window. Josh Hatwich's post on debugging can help:
Let us know if you have more questions.