Skip to Content

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.

To report this post you need to login first.

12 Comments

You must be Logged on to comment or reply to a post.

  1. Harrie Prinsen
    Hi Juergen,

    Great blog so I know more about the concept of binding data to a form using XML schema.

    I hope you can also give some examples of table sections!

    Regards Harrie

    (0) 
  2. Vivek K
    Juergen,
      Thanks for publishing this blog. In the example that you have given, if I have multiple names and I would like to display in a tabular format I could display them but it displays without column headers. Can you please advice me how I can display a coulmn header using subform for dynamically displaying the record data.

    Thanks!
    Surya.

    (0) 
    1. Juergen Hauser Post author
      Hi Surya,

      when you drag&drop a table from the “standard” library on a form a dialog is shown. In this dialog there is a check box “Include Header Row in Table” you have to mark that one.

      Cheers,
      Juergen

      (0) 
      1. Juergen Hauser Post author
        One addition: A table is an abstraction ontop of subforms. If you do not want to use a table you have to build the structure by hand. Meaning you have to add the subforms for your column header yourself.
        (0) 
        1. Vivek K
          Juergen,
            Thanks for you reply. You are right, the table control has got the header column but my understanding is that we can’t use the table control for displaying the dynamic data. I have used the nested subforms with flow content to display the grid. Using this technique I could display the data in grid format but I could not display the header. I have also tried to create a table with one header column and one data column and include the nested subforms in the first data row. This displayed the dynamic content but not in multiple table rows. Can you please advice me here.

          Thanks!
          Surya.

          (0) 
  3. Hanoz Tarapore
    Hi,

    Thanks for the blog. It has been of great help!!

    I am facing a problem with the usepdf mode.

    I have a adobe interactive form saved in the java dictionary table(as binary).
    This form can contain attachements & signatures.

    Now, depending on which user(‘role’ of user) logins into the webdynpro java application & tries to view the form, i need to set the visiblity of a few subforms within the form.
    For this to be possible, i need to pass the user-role/name to the form(using the context node).
    To achieve this, i need to open this form in UpdateDatainPDF mode. But if i do this, i wont be able to see the attachemnts/signatures,etc of the original form.
    But if i use usepdf mode, then i wont be able to pass user-role/name to the form & so wont be able to change the visisbility of the subform.

    How do i solve this problem??!!!!

    Regards,
    Hanoz

    (0) 
    1. Juergen Hauser Post author
      Hi Hanoz,

      Could you please post the question on the Interactive Forms forum on SDN? People on that forum might be able to answer your question.

      I know that you could be using scripting to show and hide subforms. But you would need to find a way to push the user information to the form (as part of the data).

      Thanks,
      Juergen

      (0) 
      1. Joseph Tshwene
        Hi Juergen,

        I have a problem with extracting data from BIW Infocube and populate certain field in the interactive form…

        My problem being; I cant read the Infocube since it is not a Flat Structure, is there a simple way of extracting the data from the Infocube and do what i’ll able to do with the Normal Sap Table.

        The other thing is, the RRW3_GET_QUERY_VIEW_DATA FM, i’v been trying to extract data from the queries which reference the Infocube, but it returns inconsistent data, like when i use the I_PARAMETER function, it cannot be able to bring filtered values.

        Please Help

        Thanks
        Joseph Tshwene
        South Africa,

        (0) 

Leave a Reply