WHY we want to do this. In the past I’ve hard coded JS arrays* to display and bind the Department and Division fields. This has worked well and has become extremely ‘popular’ with the user groups. A large number of forms already carry this coding.
However I’m concerned that if something changes in any of the values it will be necessary to manually update ALL the forms. So I’m attempting to be pro-active and develop a web service that can be accessed from each form instead!
This is the process we're trying to develop:
1. User enters their USERID into a text field and hits an execute button that will go to a web service and bring back values from a database to auto-populate 7 fields.
2. Four of the fields are drop-down lists [Department, Division, Location, and SubLocation]. Each of these fields will have two functions. [1] To automatically display the value for that specific USERID. [2] To provide a drop-list of all the other field values in case their information is out-of-date.
QUESTION: How can you bind these four drop-down fields together? For example, the sequence of events we want to automatically happen is:
- user selects the appropriate Department which causes the Division drop-down list to change to only display divisions in that department
- user selects the appropriate Division which causes the Location drop-down list to change to display only the locations for that division
- user selects the Location which causes the causes the SubLocation drop-down list to change to display only the sublocations for that location
IS THIS EVEN POSSIBLE ?? We've been able to get the 1st function working (populating the 7 fields with values from the database). But we can't figure out how to bind the fields together.
This is the code we are using to receive the data for the Department field via the web service.
<?xml version="1.0" encoding="utf-8" ?>
-
Boards and Commissions
CAO's Department
City Clerk
Community Services
EES - Env. Programs & Solid Waste
EES - Admin & Development Services
EES - Administration
EES - Fleet Facilities&Dept. Resour
EES - Roads and Transportation
EES - Wastewater and Treatment
EES - Water
Elected Officials
Environmental Services
Environmental Services - Operations
Finance and Administration
Finance and Corporate Services
Legal Services
Planning and Development
======================================================================
This is the array that is currently hard-coded into each form to bind the Division field to the Department field. (I’ve shortened the list to save space.)
var g_arrayDivisions = new Array();
//BOARDS AND COMMISSIONS
g_arrayDivisions[0] = new Array("Canadian Medical Hall of Fame", "Cross Cultural Learning Centre", "London Arts Council", "London Block Parent Program", "London Convention Centre", "London Economic Development Corporation", "London Hydro", "London Police Service", "London Public Library", "London Transit", "Middlesex-London Health
If I understand you correctly, you want to bind "List Entries", not the value, but the entries in the list, to an external data source. Which in your case is a web service.
This is feature was first offered in Designer 7.1, which was a paid update. It is also availible in Designer 8.
Just as a test, before using the web service, create an XML file with a repeated tag. Then create a new Form in LiveCycle designer and add a dropdown to it. Look in the "Object->Field" tab. The "item" text above where you add in the list items should be green and underlined like a web link. If you click on this it will bring up a dialog for binding fields in the XML to the list items.Once you've done this you can look in the XML view and you'll see an undocumented XFA property in the Field tag called "bindItems".
Open the form in Acrobat and import the XML file that you used as the template for the data source. It will populate the entries in the dropdown.
Use the same technique for setting up the web service to populate the dropdown.
You can use different functions in the webservice to populate the different dropdowns. However, if you want this to happen at different times, using differtent input data to acquire the lists, you'll need to do some quick footwork with the JS to modify the field binding at runtime to keep the other fields from being affected by the one you're working with.
There is another way to do all of this that might be easier and cause less latency on the form interactivity. And that's to connect an invisible field to a web service function that returns all the data in a big chunk, then parse it out as you need it to populate the fields. This would be similar to the techique your using right now, except that you'd be using an invisible field as the data source instead of hard coded JS values.
Hope this helps.
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script