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

make objects in subform invisible at runtime

rigateika
Registered: Mar 7 2008
Posts: 14
Answered

I created a form in LiveCycle Designer.
The form has subform2 defined as "positioned" and "Visible".
The form contain text objects, text fields and image fields. Each of them has size and position defined.

At the run time I want the objects inside the subform to become invisible depending on a field value. So i put the code in Subform2 on DocReady event:

[i]console.println("in Subform2- docready");
var TotExclTax = data.Main.APPENDIX.TOTAL.Sum.TOTEXCLTAX.FKWRT.rawValue;
console.println("TotExclTax="+TotExclTax);

if (TotExclTax == 400000)
{
this.presence = "invisible";
console.println("equal 400000");
}[/i]

At the runtime I see the message "equal 400000" in the console.
This means that statement [i] this.presence = "invisible";[/i] gets executed.
But objects in the subform stays visible!

How to make all the objects in subform Invisible?
I thought that making subform invisible will automatically make all objects inside the subform invisible too...

KathrynGZ
Registered: Apr 15 2008
Posts: 35
rigateika,

You might try putting the script on the initialize event of the form. I did something similar (though I based my show/hide on a form variable) and it works. Here's an example of the code I used:

if (varJobTitle == "AE") then
form1..Table1.Row[2].presence = "hidden"
form1.msubform.rating[2].presence = "hidden"
endif

This code hides both an individual table row and an entire subform. I used FormCalc, but with a few syntax tweaks the code should work in js too. Also, I chose "hidden" because I wanted the row excluded from the layout, but the script should work fine with "invisible" too.

Hope this is helpful--

Kathryn
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Since you want the field to hide/show on a value change, you should use one of the value related events for that field, i.e., calculate or validate. Either of these events will provide the field data at the time it changes. I prefer validate since it should only be called when the data changes. Which will minimize the number of times the script is run.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

rigateika
Registered: Mar 7 2008
Posts: 14
Thomp,

My form is NOT interactive. This is Static form designed for Print only.
I am afraid I have few events available with static form.

I have Javascript code on Client side on Docready event for some of the textfields in this form. The code is to make the textfield invisible depending on the value of another field.

But I was unable to achieve the same for Subform.

Am I trying to make working something that is not possible in Static form?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
How does data get into the form? This is very important since it defines what triggers are available for hiding and showing the fields.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

rigateika
Registered: Mar 7 2008
Posts: 14
The data gets into the form thru binding : $record.GENERAL.ACCTNG_STRING
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Ok, first you need to save the form as dynamic. On a static form, elements can only be hidden or shown on form load. By the time the DB connection is created and data is merged into the form it's already way past this time.

The events you were originally using should work for you. But the change event should also work. I think the only change you need to make is saving as dynamic. But to be sure, place "console.println" statments in all the events you are interested in. Use them to print out the data you'll be testing for the Hide/Show and watch the console window as the document loads. This will tell you exactly which events the data is valid in.

Here's an article on using the Acrobat Console window

http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/javascript_console/

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

rigateika
Registered: Mar 7 2008
Posts: 14
Thomp,

My form is not interactive, It is static. This is a requirement. The form is Purchase Order print form.
I am changing an existing form from within SAP in LiveCycle Designer made by ADOBE specifically for SAP.
However there shouldn't be difference in the form behavior for SAP LCD and regular SAP.

I am able to make text fields visible/invisible on this form on DocReady event.
For example:

if (data.pageSet.Page1.BUKRS.rawValue == "3000")
{
this.presence = "visible";
data.pageSet.Page1.Subform2.Name_BCC.presence = "invisible";
data.pageSet.Page1.Subform2.Name_COC.presence = "invisible";
}

I was hoping that making Subform invisible will automatically make textfields on the subform invisible too and I will not have to repeat same code for every textfield.

So I put the code in the Subform on DocReady event along with console.print (this will allow me to see so in debug if the event is actually fired).
When I ran this form - I could see the event gets fired. But the text fields presense within the Subform didn't get changed.

LiveCycle Designer help in chart "Differences between static and dynamic PDF forms" is saying that "Changes to the appearance of an an object are possible". They don't specifically say about the object type - Textfield or Subform...
This is why I thought that Subform will play by the same rules as textfied for the object appearance. . But it doesn't.

Rendering location
Static PDF forms render once and are displayed on the client in Adobe Reader. Because rendering is performed on the server, only small tweaks to the final output are possible on the client. For example, the value area could show a different color after the user clicks a button or exits a field.
Dynamic PDF forms render on the client in Adobe Reader and, depending on the end-user interactions, can rerender on the client several times. Changes to the appearance of an object are possible in Adobe Reader because Adobe Reader has enough information to rerender the final output. For example, objects can change color, pagination can change, and objects can appear or disappear. If the end user clicks a button that adds a new row to a table, the form is rerendered in Adobe Reader.


Thank you for your time and help,
Tatyana
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You're using the LiveCycle server to render and deliver the form, this would have been useful information to have in the first post.

So you put in the console.println and saw that the DocReady event fired, very good. Did it fire before or after the DocReady on the field? Was the data used to modify the subform visibility valid? Have you tried simply setting the subform to change visibility without testing the data? Just hard coding it to see if it works at all. Did you check the presence property of the submform after the form was rendered in Acrobat, to see if the value was set? This can be done directly from the console window.

Making the subform invisble will make all the fields it contains invisible as well. But there are several elements to your process and you need to isolate each one to find out what isn't working correctly. Is the data valid, is the visibility really being set, and if it is set, does it make the subform invisible?

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script