in

InfoPath Dev

How do I return information from webform back to infopath?

Last post 10-17-2007 09:03 AM by samuelpt. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 10-17-2007 07:19 AM

    How do I return information from webform back to infopath?

    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;
        }
    }

  • 10-17-2007 07:38 AM In reply to

    Re: How do I return information from webform back to infopath?

    Hello and welcome to our forum! You've run into a classic issue. Essentially you have multiple failure cases from the web service and want to alert the user in different ways. What you have to do is parse the return error value manually in code and then use nested else if statements (quick and dirty) to show the right error message or some other type of error message lookup to an array (better).

    Shiraz Cupala / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 10-17-2007 09:03 AM In reply to

    Re: How do I return information from webform back to infopath?

    Hi Shiraz,

    Thank you very much for your help.

    I don't know how to do what you propose; the only information I receive from the ASPX page is the http response code (200 or 201 for success, 500 for failure), through objXmlHttp.status. What do I have to do at the ASPX level to send the information, and how to I receive that in the Infopath script?

    By the way, I am required to submit to a web page (ASPX), not to a web service; I don't know if that somehow changes things.

    Once again, thank you for your help!

    Samuel

     

Page 1 of 1 (3 items)
Copyright © 2003-2007 Qdabra Software. All rights reserved.
View our Terms of Use.