Hiding SubForm in Master Page



To make the background color of my form a grey/dark grey gradient, I simply placed a subForm in the MasterPage that is the full size of the page and set its fill color. I have a requirement that the background be white ONLY when printed. I am trying to place the folowing in my prePrint event (for the highest level of the hierarchy), but it will not work.

xfa.resolveNode("DocumentName.#pageSet.Page1.Background").presence = "invisible";

Page1 is the Masterpage

Background is the name of the subForm

The code will not run when placed in the DocumentName prePrint event, but if I place a dummy button on the form and put it there, it does work. Any reason this may be happening?