Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

I was asked several times now how to change the access mode or the presence of a field on an Adobe Interactive Form so I decided to discuss these two topics.

Access Mode of Fields

Let's start with the access mode. Assume that a field named TextField1 has to be set to read only mode or to be editable. The XFA technology offers four levels of access modes (see page 491, XFA Spec 2.2). For simplicity, I use only two modes in this blog.

To change the access mode of a field (read only/editable) you have to set the property "access".

In JavaScript this looks as follows:
TextField1.access = "readOnly";
TextField1.access = "open";

For the access mode example the FormCalc script code looks almost the same. You can omit the semicolon.

Presence of Fields

Now, let’s look at the presence of a field. You can set the presence either by scripting or you can use a data driven approach. If possible I would recommend using a data driven approach.

A field can be visible, invisible or hidden (takes no space on the form layout).

To change the presence of a field you can set the "presence" property. In JavaScript this looks as follows:
TextField2.presence = "invisible";
TextField2.presence = "visible";

Note that the PDF has to be rendered as a dynamic PDF to make this work. If you have a PDF (e.g. saved from a WebDynpro app and sent to you) and you don’t know if it’s a static or a dynamic PDF you can open it in Designer and try to safe it with another filename (Save As). When the “Save As” dialog comes up look for the “save as type”. You can find it directly below the file name. Look for a “static” or “dynamic” in the type. Then you know.

A Data-driven Approach to Set the Presence

As scripting takes some time to execute it is worthwhile to think about controlling the presence of a field or a group of fields by data. You can use a subform whose min occurence is set to 0 what means that it does not appear if the data the subform is bound to does not exist. To understand the concept I suggest repeating the following example.

Create a data file that looks as follows with your favorite XML editor or simply a text editor:


 
    Sara
 

Now, open Designer and create a new form. Press the new button then drag a subform on the body page. Select the body page (page 1) in the hierarchy and then go to “object”, go to “Subform” and make the content “Flowed”. Create a data connection with the sample xml file you created before. Then, select the subform you dragged on the form (normally Subform1) and go to the “Binding” tab. There you have to bind the subform to “$record.existing” and check the “Repeat Subform for…” and make sure that there is no min count. Open the data view and drag the text field for the node “name” on Subform1. Open the form properties dialog and go to defaults. There you have to specify a data file for the preview. Look at the form in the preview tab.

To see how this example works, simply rename the data node “existing” to “existing2”. Go back to Designer and open the preview tab again. The subform with the text field for the name disappeared. You can make the subform reappear by renaming the data node back to “existing”.

The XFA technology is even more powerful. You can use choice subforms to let data determine the order of subforms. For tables this concept is called table sections. Please let me know if there is interest in a blog about that.

The properties and their values discussed in this blog are documented in the XFA Specification which can be found here:
http://partners.adobe.com/public/developer/xml/index_arch.html

Go to Part 2 and then to Template Reference.

This blog is based on version 2.2 of the XFA Spec.

12 Comments
Labels in this area