I have an infopath form that submits data to a web form (ASPX).
In this web form three things might happen:
1. Success! The form correctly saves data to the database.
2. Logic error - The user requested an operation that makes no sense (e.g., user asks to save an infopath form that was "closed/locked")
3. Exception - Error connecting to the database or doing the insert/update.
Back in Infopath, I now need to inform the user about the outcome of his request.
I am already using http status codes to determine wether the operation was successful or not, but how can I return an error code and an error text from ASPX back to infopath?
Here is the submit code I have:
function XDocument::OnSubmitRequest(eventObj)
{
var strUrl="http://localhost/projectosWorkflow/wfprojsave.aspx";
var objXmlHttp = new ActiveXObject("MSXML2.XMLHTTP.5.0");
try {
objXmlHttp.open("POST", strUrl, false);
objXmlHttp.send(XDocument.DOM.xml);
var oRespNum = objXmlHttp.status;
if (oRespNum == 200 || oRespNum == 201)
{
XDocument.UI.Alert("Success!");
eventObj.ReturnStatus = true;
}
else
{
XDocument.UI.Alert("WEB FORM RETURNED AN ERROR");
eventObj.ReturnStatus = false;
}
}
catch(ex)
{
XDocument.UI.Alert("ERROR SENDING DATA TO THE WEB FORM.");
eventObj.ReturnStatus = false;
}
}