You're using ifelse() incorrectly. Its output is to return a value, not execute a line of code.

Description is here:
https://manual.zorro-project.com/ifelse.htm