The set value inside a condition will does not return a value, not sure why but I guess this is as the querty does not know the condition until run time so cannot evaluate the value.
Try setting the variable globally before the condition then set it inside the condition
personally I prefer to use sessions within server connect repeats/ conditionals then just use set value = the session value at the exit of the script to output it to app connect