Error submitting using code - InfoPath Dev
in

InfoPath Dev

Error submitting using code

Last post 10-22-2007 11:01 AM by Greg Collins. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 10-08-2007 01:56 AM

    Error submitting using code

    Hello!

    im having this tres annoying problem submitting a form, i have all the
    form information and it works on any filename that doesnt have a
    colon, but the http:// has a colon and works fine, here is my code:

    if(  XDocument.DOM.selectSingleNode("/my:myFields/
    my:Exported_date").text != ""  )
    {
            if ( XDocument.DOM.selectSingleNode("/my:myFields/my:field117").text
    == "CIP Partners" )
            {
                    if ( XDocument.DOM.selectSingleNode("/my:myFields/
    my:ExpPerson").text != XDocument.DOM.selectSingleNode("/my:myFields/
    my:Assign_Job").text )
                    {
                            var fSuccessful = false;
                            // Set the URL of the file that you want to submit here.
                            var strUrl11 = "https://localhost/formLib1";
                            var strUrl12 = "202222-2222-2-2-2-2T22:2.xml"
                            var strUrl13 = strUrl12.replace(":", ":");
                            var strUrl1 = (strUrl11 + strUrl13);
                            XDocument.UI.Alert("Step1");
                            var strr = XDocument.DOM.selectSingleNode("/my:myFields/
    my:form_name").text;
                            var strrr = ".xml";
                            var strUrl = strUrl1.concat(strr, strrr);
                            var strUrl2 = (strUrl1 + strr + strrr);
                            XDocument.UI.Alert(strUrl1);
                            try
                            {
                                    var oXmlHttp = new ActiveXObject("MSXML2.XMLHTTP");

                                    oXmlHttp.Open("HEAD", strUrl1, false);
                                    oXmlHttp.Send();
                                    XDocument.DOM.selectSingleNode("/my:myFields/my:ExpPerson").text =
    XDocument.DOM.selectSingleNode("/my:myFields/my:Assign_Job").text;
                                    if (oXmlHttp.Status == 404)
                                    {
                                            // Put the document in the WSS document library.
                                            oXmlHttp.Open("PUT", strUrl1, false);
                                            oXmlHttp.Send(XDocument.DOM.xml);

                                            //  A 200 status code or a 201 status code indicates that the
    form has been submitted successfully.
                                            if (oXmlHttp.Status == 200 || oXmlHttp.Status == 201)
                                            {
                                                    fSuccessful = true;
                                            }
                                    }
                            }
                            catch (ex){}

                            if (fSuccessful)
                            {
                                    XDocument.UI.Alert("Document submitted successfully.");
                                    eventObj.ReturnStatus = true;

                            }
                            else
                            {
                                    XDocument.UI.Alert("Document NOT submitted successfully.");
                                    eventObj.ReturnStatus = false;
                            }
                    }else{XDocument.UI.Alert("Please Fill in the Planned Implementation
    Date Before Submitting");}
            }else{XDocument.UI.Alert("Step3");}

    }else{XDocument.UI.Alert("Step2");}

    I would appreciate any assistance i could be given on this matter

    the problem is i need to use colons as this is meant to be an upgrade
    to an existing form so i need this new sae precedure to replace the
    old forms instead of creating new ones, but the old forms use a now()
    function in the file name :/, could html codes be used, as you can see
    i tried using them but im n idiot >.<

    Best regards

    Ben

  • 10-08-2007 04:28 PM In reply to

    Re: Error submitting using code

    There are certain characters that are illegal to use in filenames:

     \ / : * ? " < > |

    http:// has a colon it it, but it is not part of the filename.... it is a protocol. That's why there's no issue there.

    HTML encoding will not make the colon a valid character. You will need to use another character.

  • 10-09-2007 03:56 AM In reply to

    Re: Error submitting using code

    Thank you for your reply,

    that was enough to kick me up the *** and make me use submission rules instead of code,

    saved me some time there! :D

     Thanks again!

     Ben

     

  • 10-09-2007 04:20 PM In reply to

    Re: Error submitting using code

    Glad to hear you got it working -- though don't be too quick to disregard code for submission. Code allows you to do better error handling and gives you the opportunity to present the user with more useful error dialogs than rules do. With rules, you're stuck with the default InfoPath dialogs, etc. Code has some advantages in handling submits.

  • 10-18-2007 01:51 AM In reply to

    Re: Error submitting using code

    Absolutely, i know code allows alot more flexibility then rules but for this specific form i needed a submission that could use colons in the name as it had to overwrite old forms, if it didnt then our workflow software would have spammed everyone involved unnecisarily(its too early to spell :p), but yes code is the far superior option when it comes to submission

  • 10-22-2007 11:01 AM In reply to

    Re: Error submitting using code

    Thanks for your comments. Good luck!

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