I have a web service that I created using Workbench, and it is using the Query Multiple Rows as XML component. It returns multiple items depending on criteria supplied by the form filler. The data is being placed into a drop down field. In order to facilitate this I followed what I had read previously in these forums, which is to load the xml into the DOM and then navigate to the nodes needed and loop through and add then into the drop down. That works great. The problem happens when I want to reset the data in the drop down in order to facilitate another query. So what happens in the form is:
A user is presented with a drop down that has two options, to 'add new object', or to 'edit existing object'.
If the user selects 'add new object', a blank form is displayed and the user can fill it out. Once the form is filled out, a web service takes the information and creates a row in the database.
If the user selects 'edit existing object' a web service fires and brings back xml data and places the data into two separate drop downs, one for 'staff lead' and one for 'departments'. When they select an option, another web service fires to query the database based on the selection. It works fine the first time. But say someone decides to change an option from either the 'staff lead' or the 'departments' drop downs, which would logically change the criteria for the query, things get crazy. I have to use the xfa.data.nodes.remove command in order to remove the nodes from the DOM so that the next query comes in and loads into the DOM correctly. If I don't do this, then the drop down keeps the previous data in it.
The problem is that once you use the command on a Dynamic form (this is important, the form must be dynamic.) things start disappearing on the form. Can't figure out why. Help...
Very important: The form needs to be a dynamic form. The problem does not happen on static forms.
I suggest that you go through a debug exercise to see what you are doing to the DOM. Create a large multiline field on the form. Make it top justified. Now you can use the command fieldname.rawValue = xfa.datasets.saveXML("pretty") to dump the results of the Dom into that field. You can see where you are adding it. Make sure that your nodes do not interfere with other nodes that are there. That saveXML() function can be used on any node in the dom ....you simply have to navigate to the desired node (i.e. xfa.datasets.data.form1.Page1.saveXML("pretty");
I have looked at the result set and everything looks good to me. I have my root node and all of the form data elements under it, then I have the staff lead, and department node. Each have a child node named repeating, (I've tried different names there and it didn't make a difference.) and inside the repeating node are the values. In my remove statement I point to the either department or staff lead nodes (depending on which I need to clear.) and go through the xfa.data.nodes.remove step. What's interesting is that somehow this command is changing the visibility of subforms, which are not listed anywhere in the data DOM? I'm more confused now.