Working in Designer ES2, I am trying to populate a dropdown list with data returned by a web service, but can't seem to get the binding right.
I created a web service using Workbench that returns the following XML data (shown here in a text field for testing purposes):
However, when I bind this to the DataDropdownList control, LiveCycle seems to be trying to put the entire XML document into the dropdown list.
Binding:
(Full text of the binding is connectionData.groupLeaderWebService.Body.invokeResponse.xmlData.document.)
Result:
So, a connection is being made and the web service is returning data, but it is not bound correctly as items in the list.
I need the dropdown list to display the individual names returned by the web service. Eventually, this will probably be expanded to include name and ID number (text and value, respectively).
Can anyone see where I'm going wrong with this? Any help would be appreciated.
Thanks!
Toby
Solved! Go to Solution.
Views
Replies
Total Likes
Whoops. Good catch. That should be pls.loadXML(form1.page1.footer.lots.rawValue,0,1);
Views
Replies
Total Likes
Toby,
This is far more complicated than most of us (any sane person) would like.You need to parse the response. I attached the SOAP message returned from a LC process. Here is the script I attached to the call to populate a drop-down.
// form1.purchaseOrder.header.invokeBtn.execEvent("click");
// loadXML() loads and appends the specificed XML document to the current object
xfa.datasets.data.loadXML(form1.purchaseOrder.header.xml_result.rawValue,0,1);
// saveXML() returns a string representing the XML fragmen of the current object
form1.purchaseOrder.header.xml_result.rawValue = xfa.datasets.data.saveXML();
var dataGroup = xfa.resolveNode("xfa.data.parts");
var dataGroupLength = dataGroup.nodes.length;
if (dataGroupLength == 0) {
xfa.host.messageBox("There are no parts in the XML doc.");
}
else {
for (var i=0; i < dataGroupLength; i++){
this.addItem(dataGroup.nodes.item(i).nodes.item(0).value);
}
}
Steve
Note. form1.purchaseOrder.header.xml_result is a hidden field.
Steve
Ha! I agree. I've really been struggling with this. Suggestions for simplification are welcome.
My core requirement is to return a list of names (and, later, ID numbers) from a database based on user input in the form. Basically, users are entering a department, and need a dropdown list of people in a certain position in that department.
Users are accessing the form via Workspace. Jasmin suggested that creating and accessing web services might be the best way to accomplish the dynamic dropdown needs. Is there a better way to go about this?
Thanks
Toby
Views
Replies
Total Likes
Thanks, Steve.
I'm trying to implement this. Can you tell me what event you placed this script in? Does it run at the client or the server?
Thanks again
Toby
Views
Replies
Total Likes
Toby,
I'll get back to you in a bit with an ES2 .lca of the process and the form. The form I referenced is part of an LC 8.2.1 process and I need to import the archived process .xml to an VMWare image running LC 8.2.1 so I can export an .lca to import into ES2, if that makes any sense.
Steve
Views
Replies
Total Likes
Steve
Frighteningly enough, that makes total sense.
Looking forward to seeing the ES2 version. Really appreciate your help.
Thanks!
Toby
Views
Replies
Total Likes
Toby,
Please send an email to stwalker.adobe@gmail.com and I will forward the assets.
Steve
Views
Replies
Total Likes
Steve
Thanks! After working with the example you sent me, I was able to get it to work -- great! However, this method seems to overwrite all the other XML in my xfa:data -- not great!
For example, without the script, I have something like this in my form data variable after a form is completed and submitted:
However, when I use the script as you described above and in your sample to load the data for the dropdown list, I get this in my form data variable:
Views
Replies
Total Likes
Hi Toby,
The data DOM is getting stomped on. I have built forms that use multiple Web Service calls to populate multiple drop-down lists. Here is the approach I have taken to add and remove a data to/from the data DOM on-the-fly.
In this example I have a drop-down called form1.page1.section3.parkingLot that calls the script object function getParkingLots() on initialize. The function performs the following:
function getParkingLots() {
var pls = xfa.datasets.createNode("dataGroup", "pls");
xfa.connectionSet.GetParkingLots.execute(0);
wb.loadXML(form1.page1.footer.lots.rawValue,0,1);
xfa.datasets.data.nodes.append(pls);
var dataGroup = xfa.resolveNode("xfa.data.pls.lots");
var dataGroupLength = dataGroup.nodes.length;
if (dataGroupLength == 0) {
xfa.host.messageBox("There was an error retrieving parking lot data.");
}
else {
for (var i=0; i < dataGroupLength; i++) {
var lot = dataGroup.nodes.item(i).nodes.item(0).value;
form1.page1.section3.parkingLot.addItem(lot);
}
}
xfa.datasets.data.nodes.remove(pls);
}
Steve
Good stuff! This is very helpful -- thank you.
Can you explain the "wb" in wb.loadXML(form1.page1.footer.lots.rawValue,0,1);?
Thanks again
Toby
Views
Replies
Total Likes
Whoops. Good catch. That should be pls.loadXML(form1.page1.footer.lots.rawValue,0,1);
Views
Replies
Total Likes
Ah! Of course.
This worked great. Thanks again for all your help with this -- I really learned a lot from it.
Toby
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Likes
Replies