Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Populating Drop Down List Items via Web Service

Avatar

20-08-2008

We have version 8.2 of LiveCycle and are trying to populate a drop down list of values via a web service. We have successfully build a web service in WorkBench that will query a database for unique values in a particular Oracle database table. Those values are required to populate the drop down list in the form. We're having a problem figuring out the approach and best practice.



The web service was created by using the "Query Multiple to XML" activity. The properties tab of the activity require the following:



b Root Element Name



b Repeating element Name



b Column Name Mappings



We have used "form1" as the root element name and "test" as the repeating element name because those are the xml structure of the PDF form in question. We then mapped the column name from our SQL query to the element name "section" in our column name mappings. Unfortunately, the resulting xml has a repeating element of "test", although that element only appears once in the PDF xml. If we leave the root element name and repeating element names blank, the resulting xml defaults to "root" and "element". Not sure what we are supposed to do in this case?



Then, in the form that we want to call this web service, we add a "data connection" using the WSDL created by our new process. When we create the data connection, I then see the invoke request and invoke response, as well as invoke button in the data view. We dragged the button onto the form and then I enabled dynamic labels in the form. For the target drop down list, I clicked on "List Items" and selected the data connections, then configured the binding. For the binding, I selected invokeResponse->outputXML->document. The problem is that the entire output xml is then entered in the drop down. It does not parse the XML output to populate the drop down.



Questions:

1) How do we do parse the XML for the drop downs?

2) Do we need to create more output variables in our web service that parses the XML into some sort of list format?

3) What are the best practices for populating a drop down list in version 8.2?



Thanks

Replies

Avatar

10-09-2008

I moved my XML within the xfa:datasets tags and then the following works.



Combobox.addItem(xfa.datasets.FormData.Manager.nodes.item(0).value);



But the xfa.datasets.FormData.Manager.nodes.length does not count the number of items.



Any suggestions? Also, Am I doing this in a way that will cause me some issues in the future?



I need a pdf form that sits on the client's computer and does not require web services.



Thanks,



Kris

Avatar

Avatar
Coach
Level 10
Jasmin_Charbonn
Level 10

Likes

149 likes

Total Posts

2,154 posts

Correct Reply

97 solutions
Top badges earned
Coach
Give Back 1000
Give back 900
Give Back 800
Give back 600
View profile

Avatar
Coach
Level 10
Jasmin_Charbonn
Level 10

Likes

149 likes

Total Posts

2,154 posts

Correct Reply

97 solutions
Top badges earned
Coach
Give Back 1000
Give back 900
Give Back 800
Give back 600
View profile
Jasmin_Charbonn
Level 10

10-09-2008

Put a app.alert(xfa.datasets.data.saveXML()); in your code.



You'll see the structure of the data DOM. That way you can write the right expression.



Jasmin

Avatar

11-09-2008

Any other suggestions on how to get a total number of items?



xfa.datasets.FormData.Manager.nodes.length does not work.



Regards,



Kris

Avatar

Avatar
Coach
Level 10
Jasmin_Charbonn
Level 10

Likes

149 likes

Total Posts

2,154 posts

Correct Reply

97 solutions
Top badges earned
Coach
Give Back 1000
Give back 900
Give Back 800
Give back 600
View profile

Avatar
Coach
Level 10
Jasmin_Charbonn
Level 10

Likes

149 likes

Total Posts

2,154 posts

Correct Reply

97 solutions
Top badges earned
Coach
Give Back 1000
Give back 900
Give Back 800
Give back 600
View profile
Jasmin_Charbonn
Level 10

12-09-2008

Can copy the content of app.alert(xfa.datasets.data.saveXML());?



I want you to do that so you can see the structure of the XML. Paste it in here and we'll help.



xfa.datasets.FormData.Manager.nodes.length doesn't make, but in order to help, we need to know the structure of your data.



If you look at my first post on this topic, the format would be somthing like: xfa.datasets.data. then the rest of your structure. Also it'll drop the root node.



So my guess would be that xfa.datasets.data.Manager.nodes.length



Jasmin

Avatar

12-09-2008

Hi Jasmin,<br /><br />I ended up using the saveXML command and most of Parth's code.<br /><br />var xmlData = xfa.datasets.FormData.saveXML();<br />var treeDataName = XMLData.parse(xmlData, false); <br />var mynodesDataName = XMLData.applyXPath(treeDataName ,"//FormData/Manager/Profile/Name"); <br />if (mynodesDataName == null) { <br /> // no data <br />} else if (mynodesDataName.length == null) { <br /> // not an array, just a single value <br /> ManagerName.addItem(mynodesDataName.value,mynodesDataName.value); <br />} else { <br /> for (var i = 0; i < mynodesDataName.length; i++) { ManagerName.addItem(mynodesDataName.item(i).value,mynodesDataName.item(i).value)} }<br /><br />But I cant help thinking since the data is in XML it cant be binded easier..<br /><br />here's the XML<br /><br /><FormData><br /> <Manager><br /> <Profile ID="1"><br /> <Name>Name 1</Name><br /> <Phone>Phone 1</Phone><br /> <Email>Email 1</Email><br /> </Profile><br /> <Profile ID="2"><br /> <Name>Name 2</Name><br /> <Phone>Phone 2</Phone><br /> <Email>Email 2</Email><br /> </Profile><br /> <Profile ID="3"><br /> <Name>Name 3</Name><br /> <Phone>Phone 3</Phone><br /> <Email>Email 3</Email><br /> </Profile><br /> </Manager><br /></FormData><br /><br />I have to run all these for statements (which not happy with) and I think it will slow things down eventually.<br /><br />Do you have an idea how to add TextBoxes, Checkboxes, Etc. via script?<br /><br />Thanks,<br /><br />Kris