Return autoincrement column on submit?

A

Adam

I have a form that queries and submits to a web service using datasets with
Infopath SP1. When the form submits, it creates an entry in a table that has
an identity column as it's primary key. I'd like to have the form inform the
user what value was given to that column for the insert. I attempted using a
series of rules for a button but to no avail. Does anyone know how I'd
accomplish that?

Thanks,
 
F

Franck Dauché

Hi Adam,

You could create a button on your form and create code that would call a Web
Service to pass the entire XML document. The XML parsing would happen within
the WS. The WS would then get all the IDs back from the DB and send them to
the calling form as return value(s).

Franck Dauché
 
A

Adam

Can you offer any more specifics? I tried simply setting the "Main submit"
data connection to use the entire xml document but that yields an error. I
assume I have to change my web service to handle this behavior. Right now
the query connection gives me a DataSet and the submit connection accepts it
and returns void. For the record here's the error from infopath:

InfoPath cannot submit the form.
An error occurred while the form was being submitted.
The SOAP response indicates that an error occurred:

System.Web.Services.Protocols.SoapException: Server was unable to read
request. ---> System.InvalidOperationException: There is an error in XML
document (33, 54). ---> System.ArgumentException: The same table
(DsApplicant) cannot be the child table in two nested relations.
at System.Data.DataRelation.CheckNestedRelations()
at System.Data.DataRelation.set_Nested(Boolean value)
at System.Data.XmlDataLoader.InferSchema(XmlElement tree, Hashtable
tableAtoms, DataTable table)
at System.Data.XmlDataLoader.InferSchema(XmlElement tree, Hashtable
tableAtoms, DataTable table)
at System.Data.XmlDataLoader.InferSchema(XmlElement tree, Hashtable
tableAtoms, DataTable table)
at System.Data.XmlDataLoader.InferSchema(XmlElement tree, Hashtable
tableAtoms, DataTable table)
at System.Data.XmlDataLoader.InferSchema(XmlElement tree, Hashtable
tableAtoms, DataTable table)
at System.Data.XmlDataLoader.InferSchema(XmlElement tree, Hashtable
tableAtoms, DataTable table)
at System.Data.XmlDataLoader.InferSchema(XmlDocument xdoc, String[]
excludedNamespaces)
at System.Data.DataSet.ReadXml(XmlReader reader, Boolean denyResolving)
at System.Data.DataSet.ReadXml(XmlReader reader)
at AppTrack.Web.Services.Data.DsApplicant.ReadXmlSerializable(XmlReader
reader) in
\\vmwebserver\wwwroot$\apptrack\web\services\data\dsapplicant.cs:line 84
at
System.Data.DataSet.System.Xml.Serialization.IXmlSerializable.ReadXml(XmlReader reader)
at
System.Xml.Serialization.XmlSerializationReader.ReadSerializable(IXmlSerializable serializable)
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read6_UpdateApplicant()
at
Microsoft.Xml.Serialization.GeneratedAssembly.UpdateApplicantSerializer.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
xmlReader, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader)
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.Invoke()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

Thanks for your help!
 
F

Franck Dauché

Hi Adam,

You may want to explore the option of creating your own Submit button where
you can call a Web Service in C#, bypassing IP default Submit option. This
way, you can get your IDs back and manipulate the by code.

Franck Dauché

Adam said:
Can you offer any more specifics? I tried simply setting the "Main submit"
data connection to use the entire xml document but that yields an error. I
assume I have to change my web service to handle this behavior. Right now
the query connection gives me a DataSet and the submit connection accepts it
and returns void. For the record here's the error from infopath:

InfoPath cannot submit the form.
An error occurred while the form was being submitted.
The SOAP response indicates that an error occurred:

System.Web.Services.Protocols.SoapException: Server was unable to read
request. ---> System.InvalidOperationException: There is an error in XML
document (33, 54). ---> System.ArgumentException: The same table
(DsApplicant) cannot be the child table in two nested relations.
at System.Data.DataRelation.CheckNestedRelations()
at System.Data.DataRelation.set_Nested(Boolean value)
at System.Data.XmlDataLoader.InferSchema(XmlElement tree, Hashtable
tableAtoms, DataTable table)
at System.Data.XmlDataLoader.InferSchema(XmlElement tree, Hashtable
tableAtoms, DataTable table)
at System.Data.XmlDataLoader.InferSchema(XmlElement tree, Hashtable
tableAtoms, DataTable table)
at System.Data.XmlDataLoader.InferSchema(XmlElement tree, Hashtable
tableAtoms, DataTable table)
at System.Data.XmlDataLoader.InferSchema(XmlElement tree, Hashtable
tableAtoms, DataTable table)
at System.Data.XmlDataLoader.InferSchema(XmlElement tree, Hashtable
tableAtoms, DataTable table)
at System.Data.XmlDataLoader.InferSchema(XmlDocument xdoc, String[]
excludedNamespaces)
at System.Data.DataSet.ReadXml(XmlReader reader, Boolean denyResolving)
at System.Data.DataSet.ReadXml(XmlReader reader)
at AppTrack.Web.Services.Data.DsApplicant.ReadXmlSerializable(XmlReader
reader) in
\\vmwebserver\wwwroot$\apptrack\web\services\data\dsapplicant.cs:line 84
at
System.Data.DataSet.System.Xml.Serialization.IXmlSerializable.ReadXml(XmlReader reader)
at
System.Xml.Serialization.XmlSerializationReader.ReadSerializable(IXmlSerializable serializable)
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read6_UpdateApplicant()
at
Microsoft.Xml.Serialization.GeneratedAssembly.UpdateApplicantSerializer.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
xmlReader, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader)
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.Invoke()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

Thanks for your help!

Franck Dauché said:
Hi Adam,

You could create a button on your form and create code that would call a Web
Service to pass the entire XML document. The XML parsing would happen within
the WS. The WS would then get all the IDs back from the DB and send them to
the calling form as return value(s).

Franck Dauché
 
Top