Expand my Community achievements bar.

dynamic setting of presence for object in master page

Avatar

Level 3

I'm having some trouble setting presence for some text fields in various master pages.  I've searched some other posts on setting presence, but haven't gotten any of the syntax that I've found so far to work.  Below is the command I'm trying to use to set the presence of my text field now.  This command is triggered when someone checks a checkbox on the first page of the form, indicating the security level of the form.  Based on what they check, the code should make visible or invisible various tags (text fields) at the top of each page, which indicate the security level.  Here my object name is Security_Privileged, and it is on a master page named Page1Master.

xfa.resolveNode("form1.#pageSet.Page1Master.Security_Privileged").presence

= "visible";

Any help on what the correct syntax is would be appreciated.

Thanks,
Emily

6 Replies

Avatar

Level 10

Did you set the file to Render as Dynamic XML Form?

Syntax seems to be correct.

Thanks

Srini

Avatar

Level 3

Yes, sorry, good question.  I should have made clear that I have already made this form dynamic.  I set all kinds of other properties for other objects that are in my main form (i.e., not in master pages).  It's just this setting to the objects on the master pages that is giving me difficulty.

One other clue...  If I type in just the xfa.resolveNode(...) and then hit period (as follows)

xfa.resolveNode("form1.#pageSet.Page1Master.Security_Privileged").

the methods that come up in the syntax help do NOT include presence.  I have lots of choices, but not presence.  Does that indicate that I need to call some other method first maybe?

Thanks again,
Emily

Avatar

Former Community Member

I am assuming that each page has that field on it ...right? The expression that you have created only will access a single field. Each field has a unique expression. To see the expression make the field editable and on th eenter event of th efield add the javascript code app.alert(this.somExpression). Now render your form and click in th efield on each page ....you will see a different somExpression for each object. Typically the page occurance number will increase. So you will need to set each of those fields off ....not just 1. You can do this with by knowing th enumber of pages and then using a for loop to go through each instance and setting the presence property off.

On your second query, the resolveNode accepts a string ......that string gets resolved at runtime into an object then the presence of that object is manipulated. At design time the product only knows that you have a string not an object hence the object assist cannot determine what should be shown. That is why you do not see anything in the object assist.

Paul

Avatar

Level 10

The easier way is select the field in the master page and choose any event in the Script editor and copy the full path of the field and use it in your script.

I put a simple page for you to go over..

https://acrobat.com/#d=-7XINC*Sygt0kAUYRqpQ1w

I used both the ways of referencing the control on Master Page.

xfa.resolveNode("TestForm.#pageSet.MasterPage1.Button2").presence = "visible";

TestForm.MasterPages.MasterPage1.Button2.presence = "visible";

Thanks

Srini

Avatar

Level 3

Hmmm.  Bit of a mystery.  My form is dynamic.  I am using the exact same syntax as your helpful example.  But my code quits anytime it encounters any reference to an object that is on a master page.  Totally confused...

Emily

Avatar

Level 10

Did you try the suggestion made by Paul in the earlier post? That may be the problem you have.

You can find the page number by using the below statement.

     var intCurrentPageNumber =  xfa.layout.page(this)-1; //Since the Instance Manager index starts with 0.

Use the current page number to construct the control reference like

     xfa.resolveNode("form1.#pageSet.Page1Master").resolveNode("Security_Privileged[" + intCurrentPageNumber + "]").presence = "visible";

You can place this script in the LayoutReady event.

Thanks

Srini