Expand my Community achievements bar.

SOLVED

Hide or Protect a Master Page button with another button

Avatar

Level 3

I have Button A on a Master Page (MP1).

I have Button B on a normal subform page (Page1).

Button B triggers multiple functions already (working). I need to add another function of hiding or protecting Button A.

Can't seem to get it working... is my path off? I even ctrl click and have Livecycle fill the path in.

Here's the example (the last line is the one in question):

on the click event

(xfa.host.messageBox("HEY!","Lock Data",2,2)==4)

{

     this.access = "protected";

     Page1.CheckBox1.presence = "hidden";

     xfa.resolveNode("#pageSet.MP1.ButtonA").presence = "hidden";

}

I even tried:

xfa.form.form1.pageSet.MP1.ButtonA

but nothing...

Scratching my head... Thank you in advance!

1 Accepted Solution

Avatar

Correct answer by
Level 7

so I tried this myself and I agree, I cannot get this to work the way I figured it should work. After several tries I decided not to try to the button on the local page and the button on the master page to hide at the same time. This is an odd behavior as I could get 2 buttons to hide on the local page. What I ended up doing is placing a script on the master page button on the calculate event:

if(xfa.resolveNode("form1.#subform.Button1[0]").presence == "hidden"){      //this is looking at the presence of the button on the local                                                                                                                          //page. If it is hidden then hide this button.

this.presence = "hidden"

}

it is not the answer to why this does not work but does give you a solution. the only other option I could imagine would both buttons on the master page. You could set a different master for the first page then the subsequent pages.

View solution in original post

8 Replies

Avatar

Level 3

A quick follow up. In testing other possible properties  I created Button C to trigger Button A.. working... so I though I could do this:

//Button B on Click event under JavaScript)

if(xfa.host.messageBox("Will you work?","WORK!",2,2)==4)

{

this.presence = "hidden";

xfa.resolveNode("ButtonC").execEvent("Click");

}

I can't understand why this isn't working. The "if" condition of ==4 is meet and "this.presence" gets hidden... why can't the result of the click stick? seems sooo simple.

Arggh! Help!! with thanks in advance.

Avatar

Level 7

So I assumed this should be easier than it was. I tried specifying the qualified path to the button on the hidden page from page one. That did not work. What i did was; create a second button on the master page. this will only be temporary. now using the new button Ctrl+Shift Click on the button you want to hide. When you get the fully qualified path (Mine looked like:  xfa.resolveNode("form1.#pageSet.Page1.MPButton").presence = "hidden") copy that and go to the page with the button. Use that on the click action and the button on the master page now disappears. I hope this helps

Avatar

Level 3

I think I did what you suggested, but no luck...

In playing around this problem more I did figured out that the path and command works... IF its just a single command.

but add another command, it does not.

And here is the real problem. why a single command works but a multiple command button doesn't?

The button works with previous commands, but add this Masterpage object command... nothing.

Avatar

Level 7

I have seen this behavior. What does the second command do? what are you viewing the PDF in?

Avatar

Level 3

The actual form had several commands that are already working.

access protects..
presence visible...

all trigged if the condition is meet by a message box. All object are on subforms... expect of course this Button 1.

the trimmed down version:

if(xfa.host.messageBox("Will you work?","WORK!",2,2)==4)

{

this.presence = "hidden";

xfa.resolveNode("#pageSet.Page1.Button1").presence = "hidden";

}

"this.presence" refers to Button 2 which will disappear. but not the latter.

The PDF has a little of everything. The button, in question, is on a page where you attach images to it. Just a standard Image Field.

Avatar

Correct answer by
Level 7

so I tried this myself and I agree, I cannot get this to work the way I figured it should work. After several tries I decided not to try to the button on the local page and the button on the master page to hide at the same time. This is an odd behavior as I could get 2 buttons to hide on the local page. What I ended up doing is placing a script on the master page button on the calculate event:

if(xfa.resolveNode("form1.#subform.Button1[0]").presence == "hidden"){      //this is looking at the presence of the button on the local                                                                                                                          //page. If it is hidden then hide this button.

this.presence = "hidden"

}

it is not the answer to why this does not work but does give you a solution. the only other option I could imagine would both buttons on the master page. You could set a different master for the first page then the subsequent pages.

Avatar

Level 3

Thank you again for your effort.

However, I couldn't get your work around to work... It actually locks the button up completely.

Placing both buttons of Master Pages also didn't work for me. Maybe my Livecycle+computer is all wonky.

BUT, your calculate check idea inspired me on a daisy chain idea.

Since the main button triggers other functions, I created a 3rd button (on the same master page) that uses your calculate statement and that works!

Credit goes to you for basically solving my problem!

But I do challenge others to find a proper solution T_T v