These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Reference to Date Field on Master Page not working

Michael Frommer
Registered: Apr 3 2009
Posts: 80
Answered

When I test the following script in the script editor, it works, but as part of a script executed from a dropdown list on a page in the Design view, it doesn't. Any ideas what's wrong?

xfa.form.resolveNode("form1.#pageSet[0].Page1.ResponseDate").presence = "visible";
"Response Date" is the name of the Date Field. I have its default presence as "invisible" on the Master Page.

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Elements on masterpages, cannot be manipulated that simple, because they appear several times in a form.
So you will have to find all instances of the specific form object.
Therefore you can use a for statement.

for (var nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++){var oFields = xfa.layout.pageContent(nPageCount, "field");var nNodesLength = oFields.length;for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++){if (oFields.item(nNodeCount).name.substr(0,4) == "Resp"){oFields.item(nNodeCount).presence = "invisible";}}}

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Michael Frommer
Registered: Apr 3 2009
Posts: 80
radzmer,

I want to thank you for helping me.

Since my original post I did realize I need a 'for' argument. I tried this one, but it would only work on the initial page of my form:

var mDeadline = xfa.form.resolveNode("form1.#pageSet..ResponseDate") for (var i = 0; i < xfa.host.numPages; i++){mDeadline["+i+"];mDeadline.presence = "visible";}

The Date Field, which initial presence = invisible, is located on the Master Page, which I have renamed "MP".
My form, which is dynamic, starts off with 2 pages, but the flowing content may cause it to expand into 3 or 4 pages.

At first I thought I needed to change the reference "resp" in your script to the actual field name "ResponseDate", but the script editor gave me the error "undefined". So I tried your script exactly as written (although I changed the presence value from "invisible" to "visible", since the initial state of the field is "invisible"), and although the script editor gives the result of "visible", impying it should work, [u]nothing[/u] happens.

By the way, I want this to execute in the Change event of a dropdown list, for which I already have a working Switch argument which currently manipulates other fields and subforms. If i cant add it to the 'cases' of the Switch, then I suppose I would need to add it to the Exit event of the same dropdown list, but adding an 'if, else' so that it executes only for a single value of the dropdown list when selected. (By the way, the dropdown lsit is set to commit on selection.)
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi Michael,

using the change event of a dropdown will not work as expected.
But you can use a hidden field as a "trigger".

So I made a sample form.
There is a dropdown list and next to it a field called trigger, that uses the values of the dropdown list in its calculate event to change the visibilty of all instances of a date/time field on the masterpage.

xfa.resolveNode("Form1.#subform.Trigger").rawValue = xfa.resolveNode("Form1.#subform.DropdownList1").rawValue; if (xfa.resolveNode("Form1.#subform.Trigger").rawValue == "A"){//Change visibility of all buttons on all instances of the masterpagefor (var i = 0; i < xfa.host.numPages; i++){var oFields = xfa.resolveNode("Form1.#pageSet.MP[" + i + "]"); oFields.mDeadline.presence = "visible";}}if (xfa.resolveNode("Form1.#subform.Trigger").rawValue == "B"){//Change visibility of all buttons on all instances of the masterpagefor (var i = 0; i < xfa.host.numPages; i++){var oFields = xfa.resolveNode("Form1.#pageSet.MP[" + i + "]"); oFields.mDeadline.presence = "invisible";}}

Sample form:
https://share.acrobat.com/adc/document.do?docid=1c55edee-1760-4056-bf18-8333beb6689f

PS: Do not add scripts to change things outside the masterpage.
In this case the script does not work properly/anymore.
If you need to change the visibility on other pages, you better use a 2nd trigger object with separate code.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Michael Frommer
Registered: Apr 3 2009
Posts: 80
radzmar,

That's the ticket. Modified it to my form and it works like a charm. Thank you so much for taking the time, especially the PDF example provided.

Perhaps you would ponder over another issue I am having, which no one has been willing to give any thoughts on. See my post [url=http://www.acrobatusers.com/forums/aucbb/viewtopic.php?pid=52708#p52708]here[/url]