Highlighted

Query for Multiple Rows as XML

Avatar

Guest

07-11-2008

Ok I've seen this topic in the forums, but have failed to get this to work within my process. Basically I have a process that has a user fill out a form, and upon submittal the form writes it's information to a database (via a data connection within the form that invokes a separate process upon submittal.), once this is done the main process is invoked and it's first step is to query that same database and bring back the data in a lower (now exposed) portion of the form that contains certain fields that track the issue history. The query brings back the xml document and I store it in an xml variable (xml_output). I then take this information and use the Set Value object to assign the returned nodes values to the location fields in the form. This works if the query returns only one row. But once the form is moved beyond the initial Task Assignment, (first user), and query returns more than just one row, the added nodes to not show up on the form, i.e I still just get information about the first row in my form. From what I've read the form should be able to recognize the xpath expression, and bring back all the nodes, by in a sense using instance manager to create an instance for each node on the form. My question is how can I get this to work. Jasmin if your still out there... Help!



Also We're using Adobe LiveCycle ES 8.0

created the process using Workbench

the form was reader enabled and saved as a dynamic PDF.



Thanks

Mike

Replies

Highlighted

pguerett

10-11-2008

Are the multiple rows appearing in the data stream? If so is the form set to render as dynamic? To verify this open the template in Designer and go to File/Form Properties. Under the Defaults Tab the last item is a dropdown that tells the server how to render the form. You want to set that as dynamic.
Highlighted

Jasmin_Charbonn

10-11-2008

"From what I've read the form should be able to recognize the xpath expression, and bring back all the nodes, by in a sense using instance manager to create an instance for each node on the form".



That's not totally true. Let me try to explain a bit here. LiveCycle allows you to merge xml data with a form. This data could drive dynamic sections to get created automatically (for example create a variable number of rows based on the number of instances of a node).



But in your case this "variable" number of rows is coming from the xml coming from the database and is not reflected probably in the xml that gets merged with the form, which is the data node of the xfaForm variable.



The setValue won't automatically set all the nodes from the db xml to the xfaForm. It'll only give you the first instance.



My suggestion here would be to use the setValue to update an entire section of the xfaForm variable as oppose to one field value. For example, maybe your rows in the from are within a container called ROWS. You could use the setValue to update the node ROWS which would contain all the rows. If the form is design to bound to the data within ROWS, the section will be created automatically.



I'm not sure if this is clear, but at least it'll start some discussion.



Jasmin
Highlighted

Avatar

Guest

10-11-2008

Thank you for the responses. Frank I have tried the override default rendering, and that seemed to cause me alot of other problems inside of Workspace. Maybe I was doing something wrong, but I couldn't even get the form to render. And that's something I probably should have added to my first message, this form needs to work inside of Workspace.

Jasmin I'm not quite sure I understand what you're saying. I'm a bit of a noob at LiveCycle so you'll have to excuse my ignorance. It sounds like you're saying to use the set value to match the form location (which would be a section/subform on the form) with the Element section of the xml file (in my case it would be root/issue ). I'll give that a shot. Is there anything else that I need to do to the form. So far what I have is a dynamic form saved as a dynamic PDF, and I've created and XML schema to be associated with the file, but it is not embedded in the form. The XML schema is mainly so that I can navigate to fields via xpath inside of Workbench. Let me know if this is wrong. Along with that I have an XML schema file for the xml that gets returned from the Query Multiple Rows as XML operation. That allows me to easily navigate through the nodes to assign node values to the proper field values. Inside the form itself, I have two nested subforms, one named flowed the other is positioned. The names denote their relative properties, hence Flowed is a flowed subform and positioned is positioned. The positioned subform is nested inside of the flowed subform and set to repeat subform for each data item. Just wanted to explain the situation a little more. I will try using the Set Value operation to set the root/issue = to the positioned subform, as I have interpreted your response as saying. If I'm incorrect please clarify. I want to thank everyone for their help with this.



Mike
Highlighted

Jasmin_Charbonn

10-11-2008

" So far what I have is a dynamic form saved as a dynamic PDF, and I've created and XML schema to be associated with the file, but it is not embedded in the form. The XML schema is mainly so that I can navigate to fields via xpath inside of Workbench. Let me know if this is wrong"<br /><br />That's perfect. I do that all the time for the same reason.<br /><br />Now concerning the data. What I'm trying to say, is that your repeating subform in your XDP is bound to an element in the schema that defines which element will drive the number of occurrences of your subform. In your case that might be the element 'issue'. <br /><br />As an example, if you merge a xml like this<br /><br /><root><br /><All_Issues><br /> <issue>My First Issue</issue><br /> <issue>My Second Issue</issue><br /> <issue>My Third Issue</issue><br /></All_Issues><br /></root><br /><br />Then you'll might get three instances of the subform.<br /><br />Now from the process side of things you need to build the same structure for the rows to work.With xPath you can only set one element at a time, so you would only be able to set 1 'issue' at a time. Because of that I'm suggesting to update <issues> (which contains all the issues). That way you don't have to worry about the number of 'issue' you deal with.<br /><br />So if you db query returns something like<br /><br /><dbquery><br /> <resultset><br /> <issue>data 1</issue><br /> <issue>data 2</issue><br /> <issue>data 3</issue><br /> </resultset><br /></dbquery><br /><br />you could map the issues from the db query to the xfaForm variable with a single xPath statement. Something like<br /><br />xfaForm/data/datasets/data/All_Issues = xmlvar/dbquery/resultset<br /><br />That way you populate the All_Issues node directly from the query from the database. <br /><br />I hope that a bit more clear.<br /><br />Jasmin
Highlighted

Avatar

Guest

10-11-2008

Ok I tried it an no dice. Here is a snippet of the xml I'm working with:



0016-03-30
Mike
Public Works
alone in the dark
Type sleep
-1
Council
FYI
Important


0016-03-30
Mike
Public Works
alone in the dark
Type sleep
-1
Council
FYI
Important


0016-04-30
Me
Public Works
Tony Blue
Who knew
-1
Council
FYI
Important



And my Xpath expression looked like this:

/process_data/formData/object/data/xdp/datasets/data/form1/Page1/flowed/positioned = /process_data/xml_Query_Return/root/issue

Bottom portion of the form still comes up blank.

Any suggestions?
Highlighted

Jasmin_Charbonn

11-11-2008

Ok, you're mixing a few concepts here. Let's take a step back.



Let's forget about Workbench for now and focus on the form and the data being merged with it.



Form Designer allows you to create a form template (XDP). LiveCycle Forms allows you to merge a data file (XML) with that XDP to populate a form. This data can drive dynamic sections in the form.



Now in Form Designer your form contains a certain structure (from hierarchy tab). You have a subform name (flowed and position), field names etc. Now you can bind xml elements from the data that's going to be merge with element of you form. You can set that the xml element 'issue' will be bound to the subform 'position'. This binding has to be done in the form design. You can't set that with an xPath from Workbench. In Workbench, you'll only be able to provide the XML to merge with the template. The logic is in the form design.



So you have some work to do on the XDP ahead of time. You can save the xml you're planning to use in a file on the file system and use it to preview the pdf within Form Designer to see if your binding is set properly. You can go under File/Form Properties/Preview and specify a data file to test with.



Make sure this works before you even attempt to use it the process. Once this works, you can use Workbench to prepare the same data structure, but Workbench won't do the mapping for you.



This topic might be an interested read http://livedocs.adobe.com/livecycle/8.2/wb_designer/000102.html



Jasmin
Highlighted

Avatar

Guest

11-11-2008

Ok I think I finally get it. Just a couple of questions, should I use the xml schema file that I have describing the xml file to do the binding, or should I just bind using the xml file? The other question is do I need to bind (I'm reading bind as embed, tell me if this is wrong.) the xml schema file that I have for the form to the form? Thanks for all your help, Jasmin. I'm going over the livedoc that you posted now. Good stuff.



Mike
Highlighted

Jasmin_Charbonn

11-11-2008

"should I use the xml schema file that I have describing the xml file to do the binding, or should I just bind using the xml file?"



It's up to you. You can do both. The advantage of using a schema is that you can embed it in the form and it allows you to use xPath to go down the data node in Workbench.



"The other question is do I need to bind (I'm reading bind as embed, tell me if this is wrong.)the xml schema file that I have for the form to the form"



The binding is necessary to tell which element in the schema (or xml data file) is going to drive the number of subforms. Just like if you needed to populate a field with a value from the schema, you would need to bind the field to the schema element to get the value in the field.



Jasmin