Expand my Community achievements bar.

processFormSubmission xfaForm question

Avatar

Former Community Member
Hello All - I've written a servlet that simply takes a PDF document and calls a process I have written. In the first step in the process I'm trying to use the processFormSubmission service to process the PDF submission. I'm trying to get the output of the service into an xfaForm variable but I'm having no luck. Whenever I try to set the FormsResults' outputContent to xfaForm variable I get a coercision exception.



My ultimate goal is to use information from the form to make decisions in the process. I've also tried just using the processFormSubmission's "Output XML" but it requires me to use a "document" variable. I need to apply a schema to it so that I can drill down into the data in my process.



Any help would be greatly appreciated.

Bryan
14 Replies

Avatar

Level 10
Once you have the XML in a document variable, you can use a Set Value operation (under Foundation) to assign it to a variable of type XML.



Then you can assign a schema to a XML type variable.



Jasmin

Avatar

Former Community Member
Jasmin - That is kind of working. The problem now is that when I assign it to the the XML variable it's assigning the whole xdp data so the schema is not matching up.<br /><br />Here's what I get in the XML variable:<br /><br /><?xml version="1.0" encoding="UTF-8" ?> <br /> <?xfa generator="XFA2_4" APIVersion="2.6.7116.0"?> <br />- <xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/"><br />- <xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><br />- <xfa:data><br />- <Form-20-968B><br /> <Name>Bryan Dunbar</Name> <br /> <Years>20</Years> <br /> <Employer>Cardinal Solutions</Employer> <br /> <PurchasedYear /> <br /> <TotalYears /> <br /> <AccountNumber>122334</AccountNumber> <br /> <convertToTiffFlag>1</convertToTiffFlag> <br /> </Form-20-968B><br /> </xfa:data><br />- <dd:dataDescription xmlns:dd="http://ns.adobe.com/data-description/" dd:name="Form-20-968B"><br />- <Form-20-968B><br /> <Name /> <br /> <Years /> <br /> <Employer /> <br /> <PurchasedYear /> <br /> <TotalYears /> <br /> <AccountNumber /> <br /> <convertToTiffFlag /> <br /> </Form-20-968B><br /> </dd:dataDescription><br /> </xfa:datasets><br /> <pdf xmlns="http://ns.adobe.com/xdp/pdf/" href="file:///C:/Documents%20and%20Settings/bdunbar/Local%20Settings/Temp/_ceg1370k3e07d9jr.pdf" /> <br />- <xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve"><br /> <annots /> <br /> </xfdf><br /> </xdp:xdp><br /><br />My schema looks like this: <br /><?xml version="1.0" encoding="UTF-8"?><br /><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><br /> <xs:element name="Form-20-968B"><br /> <xs:complexType><br /> <xs:sequence><br /> <xs:element name="Name" type="xs:string"/><br /> <xs:element name="Years" type="xs:string"/><br /> <xs:element name="Employer" type="xs:string"/><br /> <xs:element name="PurchasedYear" type="xs:string"/><br /> <xs:element name="TotalYears" type="xs:string"/><br /> <xs:element name="AccountNumber" type="xs:string"/><br /> <xs:element name="convertToTiffFlag" type="xs:boolean"/><br /> </xs:sequence><br /> </xs:complexType><br /> </xs:element><br /></xs:schema><br /><br />So I need just the <xfa:data> portion of the data. Any thoughts?

Avatar

Level 10
When you designed you XDP did you bound your fields to a data connection that uses a schema?



If not, make sure to create a data connection created from a schema and bind your fields to it.



The data that's going to be submitted should then conform to that schema.



Jasmin

Avatar

Former Community Member
I noticed that the only times the form works for me in the WorkSpace is

either

(1) no Data Connection defined in XDP at all

or

(2) the schema and form fields have exact 1-1 binding... 3 fields in schema with 3 form fields and all 3 are binded.



any other types of binding gave me various ALC-WKS errors...

say, a schema has 4 fields, the form has 100 fields, and I only bind 2 of them... that seemed to be a no-no.



The Form Designer also showed some yellow warning icons.

Avatar

Former Community Member
Jasmin - I do have the XSD bound to a schema (its the schema I have in the above message).



I'm wondering if this will work (I'll probably try it when I get to work on monday) - just create an input variable of type xfaForm and do not use the processFormSubmission service at all. I'm thinking that I'm running into issues because I'm submitting this data through a servlet not through workspace.

Avatar

Level 10
When you submit the PDF through workspace, the submit action just send the data back to the process.



If you implement your own submit button and submit to a servlet, then you decide what you submit. You can submit the whole PDF, or just the data.



Do you need the whole PDF in your process or just the data?

If you just need the data, then you could change the parameters of the submit button and make sure you just POST the data back to your servlet and not the whole PDF.



You can alway use a render form operation to recreate it.



You can also use the Form Data Integration service under Common to extract the data from the PDF.



I'll follow up as well on Monday.



Jasmin

Avatar

Former Community Member
I do need the whole PDF, the second part of my process will check a flag in the form, and if the flag is set it will archive the PDF as a tiff image.



The basic process flow is:



1. Submit form to servlet (outside workspace).

2. Extract xml data to make certain business decisions.

3. If archive flag is true, convert the submitted PDF to tiff and store (for this POC just storing to a hard coded location, but this will end up calling a web service to store in share point).



Thanks again for all your help,

Bryan

Avatar

Level 10
Have you tried to set the Populate XML Data property to true and the Export Data Format to XML Data on the processFormSubmission operation?



Have you also tried the exportData operation from the Form Data Integration?



Jasmin

Avatar

Former Community Member
Yeah tried it and getting a different exception:



Caused by: com.adobe.livecycle.formsservice.exception.ProcessFormSubmissionException: com.adobe.livecycle.formsservice.exception.FormServerException: Option: ExportDataFormat Invalid value: XML Data

Avatar

Former Community Member
Could you manage to resolve this problem Bryan? I'm facing the same, when I extract data from a PDF using exportData service and log the variable. It appears as XDP but I want XML because I want to render the form again in later stage.



Regards,

Sunaif

Avatar

Former Community Member
I would use the exportData service under Common. this will give you your data as a document. Then you can use a setValue operation to put the document contents into an XML var. Now you can use XPath on the XML var to do what you wish.

Avatar

Former Community Member
I did the same Paul but when I drill down the XML to get the perticular field I gets a null instead of the field value. But when I see the whole XML variable, it has the data. What could be the problem?

Avatar

Former Community Member
My guess is that the XPath statement to get to the node you want is incorrect. I use the search facility to get to the node I want. So your XPath expression should look something like this:



/process_data/XMLVariable//node to search for



Hope ths helps

Avatar

Level 8
Level 8
Hi all,



WHat Paul is describing will work - however you have a problem if you have identical nodes in your xml.



Anyone who knows what to do if that is the case?



Sincerely

Kim