I'd put all of the logic for your button in its ow...
# suitescript
c
I'd put all of the logic for your button in its own module too and just include it (no need to deploy or anything) and use it to make it clean