Stefan Cameron on Forms
Building intelligent forms using Adobe LiveCycle Designer

Dynamic Properties

Did you know that as of Designer 7.1, there’s way to automatically populate certain field properties with data without having to write any script? This is what the new Dynamic Properties feature is designed to do.

First, you have to enable it because it’s disabled by default. You can do this by going to the Data Binding panel in the “Tools | Options” dialog. There, you’ll find a check box labeled, “Show Dynamic Properties”. Check the box and press OK. After doing so, put a list box (for example) on the form and take note of the changes in the Object palette’s Field, Value and Binding tabs.

You’ll notice that some property labels have now changed color (default is green) and are underlined. You can now click these property labels to make the properties they pertain to dynamic (i.e. to automatically push values into them when data is loaded into the form via a certain data connection that you specify). For instance, the Field tab now has dynamic Caption and List Items properties.

If you click on the List Items label, you’ll get the following dialog (this screen shot shows the properties already configured for this sample):

Using the Dynamic Property dialog (above), you can then specify the data connection from which the data will be loaded and also the data node(s) that will contain the data (in this case, for a list field, you can bind data nodes to the text and value items of the list).

Download Sample [zip]

Minimum Requirements: Designer 7.1, Acrobat Pro 7.0.5

Note: If you open the form in Acrobat, don’t forget to import the data into it using the “File | Form Data” menu.

For this sample, we’re trying to list all the movie titles and, when a movie is picked from the list, display its show time in a date/time field on the form. Therefore, we’ve bound all movie data

$record.movie[*]

to the list and then we’ve bound the text items to the

title

data node (which translates to “$record.movie[*].title” since it’s relative to the property’s binding) and the value items to the

showTime

data node (which translates to “$record.movie[*].showTime”).

Based on these settings for the list’s text and value items, the list will be automatically populated with all movie titles and show times when the movie data is imported into the form. All this without having to write a single line of script!

By the way, if you’re curious about the script you would have to write in order to do the equivalent without using the Dynamic Properties feature, just drop a “Data List Box” or “Data Drop Down List” object, from the Library palette’s Custom tab, onto the form and have a look at the script in its Initialize event. Now that’s not simple script! Of course, there are advantages to using script over Dynamic Properties because script is more flexible but in this case, there’s really no need to worry about using script.

Once you’ve filled-in the properties inside the Dynamic Properties dialog for the list box’s List Items property, you’ll notice that the property’s label now has a little “link” icon to signify that the property is bound to nodes in a data connection:

Finally, you just need a single line of script in the list box’s Change event to display a selected movie’s show time in a field on the form (in FormCalc):

ShowTime = $.boundItem(xfa.event.newText)

Please note that the Dynamic Properties feature is still in its early stages therefore it only handles simple data binding situations like the one for this sample. Many customers who’ve discovered this feature attempt to use it in dynamic subforms in order to populate lists with data pertaining to the current record and soon discover that the lists always end-up containing identical record data when they use the Dynamic Properties feature. That’s because the feature simply doesn’t yet support dynamically updating the data node occurrence which is used to populate a list, for example (that is, updating the occurrence of the “$record.movie” binding to a specific occurrence as opposed to always using [*]).


Posted by Stefan Cameron on July 29th, 2006
Filed under Data Binding, Tutorials
You can skip to the end and leave a response. Pinging is currently not allowed.

21 Responses to “Dynamic Properties”

  1. Raf on July 30th, 2006

    We’re using this ‘dynamic properties’ feature for translations of our forms. All captions, dropdownboxes, etc are filled dynamically.

    I always found it very strange that almost all interactive form objects have dynamic properties, except the radiobutton! It seems that the only way to fill the caption of a radiobutton is by using custom scripting? Will this be covered in the next version of Designer?

  2. Stefan Cameron on August 1st, 2006

    Raf,

    That’s an interesting idea and I’m sure it would be very useful!

    The fact is that there are still many field properties to which the Dynamic Properties feature could be applied. We just didn’t have time to implement them all the first time around.

    I’ll submit an enhancement request for using the Dynamic Properties feature to set the caption of a radio button and will update this post if it ever gets implemented.

  3. Bob Banik on February 23rd, 2007

    I am having a problem when creating a List Box using the Dynamic Properties feature. I am able to generate a List Box with LiveCycle Designer showing the Item Text but not the Item Value. I have tried several combinations of variables, but with the same result that only the Item Text is displayed in the PDF form.

    Can you suggest what I should do to display both the Item Text and Item Value in the form after importing XML data source ?

    Thanks in advance.

  4. Stefan Cameron on March 6th, 2007

    Bob,

    By definition, a list box has two types of items: text and value.

    If only text items are supplied, then the value of the list box is set to the text item which gets selected and which is also displayed.

    If both text and value items are supplied, the text items are visible and the value items are always invisible. When an item is selected, the list box’s value is set to the value item which corresponds to the text item that was selected.

    If you want to see the value items in the list using the Dynamic Properties feature, you would either have to map the value data to the text items and use only text items in the list box (where the list box’s value is the same as the selected item’s text) or the application generating the XML data would have to combine the text and value data nodes into a single data node so that you could map it to the text items.

    Another alternative would be to write a script in the list box’s Initialize event which would re-arrange the list items such that the text items contain the text and value combination and the value items remain unchanged. Since the Initialize event occurs after the data has been merged with the form, the list will be populated with your XML data when the Initialize event occurs.

    You could achieve this using the new List Object Properties and Methods if you’re using Designer 8.0.

  5. Aaron Lim on August 2nd, 2007

    Hello Stefen,

    Some questions on Dynamic Properties:-

    1. In Item Text, you use “text” value. This will only display the text description. It does not display the value “key”. Is it possible to display both? That means display like this. “IL - Illinois”. Whereby IL is the Item Value. And Illinois is the Item Text.

    2. Created a textfield. This textfield is to display dropdown description. That means displaying the Item Text value. The declaration looks like this. xfa.form.data.#subform[0].DE_Empty[2].DEContent.ISR_TextDisplay.rawValue = xfa.form.data.#subform[0].ISR_DDL_NoSelected.value.#text ;
    ISR_DDL_NoSelected is the dropdown. ISR_TextDisplay is the textfield. However, it only display Item Value. It does not display Item Text.

    Please advice.

    Hope to hear from you soon.

    Thank You,
    Aaron

  6. Stefan Cameron on August 17th, 2007

    Aaron,

    In response to your questions:

    1. Using Dynamic Properties, there isn’t a way to automatically combine, if you will, the item text and value data. If you need it displayed that way, you’ll have to use the traditional method of loading data into a list (using “xfa.data”) which will give you more flexibility and therefore the ability to set whatever you like for the item text data.
    2. The reason why you’re only seeing the item value data is because that’s what’s stored in the drop down list’s value when an item is selected. You would be better-off scripting the drop down list’s Change event such that you set the text field’s value to the selected text in the drop down list. You can do this by using the “xfa.event.newText” property in the Change event which will be set to the selected item text data:
      TextField1.rawValue = xfa.event.newText;
  7. Michael on August 22nd, 2007

    Hello Stefan,

    I am a beginner in Adobe Designer and I have some difficulties to import xml data in a drop down list.
    In fact, I work with Adobe Designer 7.0 so I don’t have this dynamic properties.

    So to make the binding I try different plans:
    1- I create a datasource, I drag on my form the list, in the binding part of the list I choose my datasource with the data wanted. The result is in the preview I have no data :(
    2-I create a datasource, I write script to put xml data when the list is initializing. The result is in the preview I have no data :(
    3-I download your sample and I look how it works. So in a new test, I create a datasource, I drag a list in my form, I put my xml data in file->form properties->details->preview->data file, I add in the xml source of my form the balise BindItems to the field of my list like your sample . The result is in the preview I have my data. :) But when I open the pdf in Reader the data are not here. :(
    4-So I take again the first try and I add my xml file in form properties->preview…, like this in the preview I have only the first record :(

    So I have always my problem : how import xml data in a drop down list ? how do to have this data in the pdf in output to read it in the Reader?

    Thanks for your response

    Best Regards

    Michael

  8. Stefan Cameron on September 2nd, 2007

    Michael,

    Unfortunately, even if I explained to you how to import items from XML data into your drop down list without the use of the Dynamic Properties feature in Designer 7.1, you still wouldn’t get anywhere if you’re only using Reader to “run” your form. Reader, on its own, cannot import data. The PDF form that it opens must be extended using Adobe LiveCycle Reader Extensions ES in order to enable Reader’s hidden “data import” feature when that PDF is being used. The reason why you can get this to work in Reader using Designer is because when you specify a preview data file, Designer manufactures a PDF with the data already merged into it prior to giving it to Reader to preview (which means Reader isn’t part of the data import/merge process which it can’t do on its own). When you distribute this form to other users who only have Reader, they’ll have to use Reader to import/merge the data and they won’t be able to do it. That is, unless you’ve extended the PDF.

    Acrobat Standard and Professional can import data into a PDF without requiring the PDF to be Reader-Extended.

    If you’re able to Reader-Extend your form or if you can use Acrobat Standard or Pro instead of Reader, let me know and we can work at importing the data using script.

  9. Mike on July 31st, 2008

    Hi Stefan,

    Like the other Michael, I am very much a beginner at using Designer 7.0. What I’m trying to do is have two checkboxes, and when either is checked, filling in one of two lists of 7 items into a dropdown list, then having the choice on the dropdown list populate another dropdown list. I would also like to do this without having to link it to an XML source and be usable in Reader. Firstly - is that possible? Secondly - how do I do it?
    I have tried going through the FormCalc User Reference, but not being from a programming background, not much of it makes sense! I can get very basic scripts working, such as message boxes appearing, and I have made the dropdown lists and checkboxes, but I can’t link anything.

    Hope you can help,
    Mike

  10. Stefan Cameron on August 8th, 2008

    Mike,

    If you aren’t using any kind of data connection, it implies that you’re loading all these list using script. I would recommend you use the Change event of the checkbox objects to execute some script that would populate the right drop down list. To populate a drop down list, you simply use the addItem() method:

    myDropDownList.addItem("Item 1");

    You can do this either in FormCalc or JavaScript. I strongly recommend you get used to using JavaScript.

    As for populating the second drop down list when a selection is made in the first one, I would script the Change event of the first drop down list, check what the user selected and populate the second drop down list accordingly:

    var newSelection = xfa.event.newText; // text value of the item that was selected in the drop down list
    
    if (newSelection == "Item 1")
        myOtherDropDownList.addItem("Item 1a");
    else if (newSelection == "Item 2")
        ...
  11. Rob Baptiste on August 29th, 2008

    Stefan I am in need of some desperate help.
    I am trying to create a small calendar within an interactive form using Adobe FormDesigner 8 where the user can initiate a button click event for that particular day which will cause text and a hidden text box to appear in a text field. I was able to successfully have images appear in an image field with a button click event but cannot get the text to do the same. The JavaScript code that I used for the images is as follows:

    Button 1
    var image = StaticImage1.value.image.value;
    newImage.rawValue = image;

    Button 2
    var image = StaticImage2.value.image.value;
    newImage.rawValue = image;

    If you can help me in resolving this matter is quickly as possible, this would be a blessing thank you.

  12. Stefan Cameron on September 9th, 2008

    Rob Baptiste,

    I dont’ quite understand what you mean by having “text and a hidden text box appear in a text field”. If you’re just trying to get text to appear in a text field, you just need to set the text field’s rawValue property:

    MyTextField.rawValue = "text";
  13. Satish Janardan on September 11th, 2008

    Hello Stefan,

    I am new to form designing so sorry for simple questions. I am trying to use drop down list to select a name and automatic have the address field like street,city,state, zip filled in. Do you have an example of this?

    Thanks much for you help.

    Satish

  14. Stefan Cameron on September 12th, 2008

    Satish Janardan,

    You’ll need to script the drop down list’s Change event in order to accomplish this. Using the “Window menu > Script Editor” command to show the Script Editor palette, choose the “Change” event from the “Show” property and set the language to “JavaScript”.

    First, you’ll need to get the new selection in the list:

    var newSelection = xfa.event.newText;

    Then you’ll need to figure-out what it is:

    if (newSelection == "Person 1")
    {
        // user selected "Person 1" so fill-in the street, city, state and zip fields with information about "Person 1"
        Street.rawValue = "123 Main St";
        City.rawValue = "Los Angeles";
        State.rawValue = "CA";
        Zip.rawValue = "12345";
    }
    else if (newSelection == "Person 2")
    {
    }
    else if...

    Of course, this assumes that you have fields named “Street”, “City”, “State” and “Zip”.

  15. Ronnie on September 28th, 2008

    Hi Stefan,

    I’m sure you can help me with my problem which is a bit similar to the previous one: I need to design an interactive purchase order form where the user clicks on a particular button below an image and the corresponding, article number,description and price are automatically entered into the PO Form- Subsequent articles should be automatically entered below the last one. Is this possible? I have already designed a form where this works with a drop down list but it is not user-friendly since one needs to remember the article number to be able to chose from the drop down list and my article numbers run into 100s:-)!
    Thanks

    Ron

  16. Stefan Cameron on October 4th, 2008

    Ronnie,

    It’s definitely possible. You could use a table with a repeatable row (select the row and in “Object palette > Binding tab” set it to “repeat for every data item”). Making it repeatable will give you the ability to add/remove instances of the row using its Instance Manager. Once that’s setup, the Click event on a button associated to a product image would add a new instance of the row, get a reference to that new instance (remember, the Instance Manager’s addInstance() method returns a reference to the new instance) and set the instance’s article number, description and price fields with the information pertaining to the related product:

    var newRow = MyTable._MyRow.addInstance(0);
    newRow.ArticleNumber.rawValue = "123";
    newRow.Description.rawValue = "product description";
    newRow.Price.rawValue = 199.99;
  17. Ronnie on October 29th, 2008

    Thankyou so much Stefan!

    I think your table method would only work in Designer 8 and above. Is there a way I could possibly do the above (interaction 15.) in Designer 7. Would be great if you could help me out with this!
    Thanks

    Ron

  18. Stefan Cameron on November 4th, 2008

    Ronnie,

    Tables are actually just nested subforms. If I recall correctly, tables were introduced in Designer 7.1 but the Instance Manager has been around since the beginning.

    A table is essentially a flowed subform that contains other subforms which may or may not be flowed themselves. Each subform in a flowed subform can be repeated and so my sample from comment # 16 would apply to a repeatable subform inside a flowed subform. (Don’t forget to set the “Object palette > Binding tab > Repeat Subform for Each Data Item” property to make the nested subform repeatable.)

  19. Ronnie on November 10th, 2008

    Hi Stefan,

    Sorry for troubling you once again-but I just don’t seem to get this addinstance() method. I am now working with Designer 8. For my problem in #15, I tried the code you have given in interaction #16 but it doesn’t work-I think the problem lies in referencing the repeatable subforms-which I am probably not doing properly. I am giving the folowing code under the click event of the Button1:

    —– form1.Sub1.Subform1.Button1::click: - (JavaScript, client) ———————————–

    var newRow = Table1._Row1.addInstance(0);
    newRow.ArticleNumber.rawValue = “123″;
    newRow.Description.rawValue = “product description”;
    newRow.Price.rawValue = “199.99″;

    This is my heirarchy:

    -form1
    -(Master Pages)
    -Page1
    Untitled Content Area
    -Sub1
    -Subform1
    -Table1
    -Header Row
    -Cell1
    -Cell2
    -Cell3
    -Row1
    -ArticleNumber
    -Description
    -Price
    Button1
    (Referenced Objects)

    -The Table has been created in Subform1 (Content type has been set to Flowed).
    -Row1 has been set to “Repeat Subform for Each Data Item”
    -Min Count is 1

    Would really appreciate your help.
    Thanks

    Ron

  20. Ronnie on November 10th, 2008

    Hi Stefan,

    I forgot something-How do I reference the repeatable subform in the Table object, if the button with the addinstance method is on another page (see #15-I wanted to make a Purchase Order with the images of the products and the ‘Buy’ button just beneath it- the user clicks on the button and the product details are automatically entered into the Purchase Order form at the end) ?
    Thanks

    Ron

  21. Stefan Cameron on November 10th, 2008

    Ronnie,

    I don’t see anything wrong with your code to add the row. I’m wondering if you saved your form as a static PDF (or if you saved it as an XDP and are previewing it as a static PDF). Static PDFs cannot add/remove instances, show/hide fields, etc.

    To check, comment-out the code in your Button1 object’s Click event and put this code instead:

    this.presence = "hidden";

    Preview your form and click on the button: If it disappears, then you’ve got a dynamic PDF and there is, in fact, something wrong with your code to add the rows. If it remains visible, then you’ve got a static PDF and that’s the problem.

    See my article on previewing as a dynamic PDF to make sure you’re previewing in the correct format.

Leave a Reply

Alternate Help: Unfortunately, I am not always able to keep track of older posts. Please feel free to continue discussions here or seek help at an Adobe Forum: Designer/Acrobat, Designer ES, Designer (v6-v8), Acrobat, Reader.

If you're including scripts: To make sure your script and comment are properly interpreted, please make sure you replace any less-than ("<") characters with their character code equivalent: "&lt;" (without the quotes). Otherwise, your script and comment will inadvertently be cut short.