Preventing InfoPath Form Submission - InfoPath Dev
in

InfoPath Dev

Preventing InfoPath Form Submission

Last post 02-05-2006 04:49 AM by DavidCrabbe. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 01-29-2006 11:45 PM

    Preventing InfoPath Form Submission

    I'm having an issue with preventing form submission where such submission bypasses the custom form validation I've written.

    I've disabled the Submit button on the toolbar and the only method of submitting the form normally is using a button with .NET code behind it.

    However when viewing the form, if the user closes InfoPath, they are prompted by the application to submit the form and can do so as InfoPath calls the Submit functionality directly, bypassing my validation.

    Is there anyway to prevent InfoPath from prompting the user to submit when the application is closed? Because I'm submitting to a web service, the OnSubmitRequest function is never called so I can't do any validation on the form in this circumstance.

    (Seehttp://www.infopathdev.com/forums/topic.asp?TOPIC_ID=1205 for details of my meanderings on the topic of OnSubmitRequest().)

    I have a fairly iffy workaround but I'm hoping that someone can suggest a way to work with InfoPath instead of against it. :)

    Thanks,
    David.

  • 01-30-2006 10:19 AM In reply to

    Re: Preventing InfoPath Form Submission

    Hey David...

    Is this form K2 enabled? Are you still using the submit task pane that K2 injects into your IP Form?

    One idea, which I have not tried, but should work would be not to use the task pane. Maybe you could try adding a button to your form >> Then go to general properties >> on the action dropdown, select submit >> in the Submitting Forms prompt select Enable Submit Commands and buttons >> then select Custom Submit using form code. Then you could possibly add some validation in there first, and if that validation does completes, you could call the K2 infopath webservice to submit you xml...
    Jason
    http://www.k2distillery.com/
  • 01-30-2006 12:26 PM In reply to

    Re: Preventing InfoPath Form Submission

    Hi David,
    Not sure if this helps you but, try this one thing, disable save option in Tools->FormOptions->Open and Save, Uncheck "Save and Save As" checkbox. Click ok button, and test it out!
    What happens if you disable "Save and Save As" checkbox is, InfoPath does not prompt user to save the form even when it is dirty in other sense if there is any unsaved data.

    Agni
    InfoPath Dev India
  • 01-30-2006 11:07 PM In reply to

    Re: Preventing InfoPath Form Submission

    Thanks for your replies...

    The form is K2 enabled, I'm using a button control on the main form to initiate the submission process to K2 and I've disabled the K2 task pane.

    Maybe it's just me, but I've found that when submitting data to a web service using a button control on the form, the OnSubmitRequest() method isn't called. Therefore I had written my form validation in the code executed when the user clicks on the button.

    However I've discovered when the user is prompted to submit the form upon closing InfoPath, the OnSubmitRequest() method *is* called so I've placed a call to my validation routine from within there.

    I have also unchecked both Save and Save As on the Form Options dialog box, thanks for the suggestion.

    Problem solved!

    David.


  • 01-30-2006 11:18 PM In reply to

    Re: Preventing InfoPath Form Submission

    I wish I was less hasty with my last reply...

    I can't seem to get OnSubmitRequest() to be called under any circumstances once I've attached my form to the K2 Workflow.

    Users are still prompted to submit a dirty form, and doing so bypasses the validation offered by OnSubmitRequest() or my custom code.

    Hmmm. Problem not solved.
  • 01-31-2006 08:51 AM In reply to

    Re: Preventing InfoPath Form Submission

    I have not run into this problem because my client wanted to use the custom taskpane and I wend down the path I described in the link you provided above.

    I am really surprised you are saying that you have a form with a button control on it that will submit. You subsequently add an OnSubmitRequest() to do some validation prior to the submit and after you hook the IP from into K2, the OnSubmitRequest() does not get called anymore. I will take a look shortly but standing on my head right now on an implementation deliverable... Maybe just check the properities of the button before and after integration the IP from into K2 and see is K2 is mucking around with the form in some unexpected way.

    Side question - Did you basically take all of the script code from the task pane and move it into the IP form's script file and call if that code from your button control?
    Jason
    http://www.k2distillery.com/
  • 01-31-2006 06:32 PM In reply to

    Re: Preventing InfoPath Form Submission

    Hey David,

    It looks like you are right. I did a very simple test where created a blank form add the following code:

    Sub XDocument_OnSubmitRequest(eventObj)
    XDocument.UI.Alert("blah")
    End Sub

    When I pressed preview, prior to publishing the form to wss and hooking it into K2, I would get a prompt when I press submit in the task bar.

    After I hook the form into a K2 process and then open the form and press the submit button in the task bar, I do not get the prompt anymore and the form gets submitted to InfoPath. So, to try to figure out what is going on, I extracted all of the files of form before I hooked into K2 and then I extracted the files after I hooked IP into K2. The most interesting change I saw was in the manifest.xsf.

    Before:
    <xsf:submit caption="Su&bmit" disableMenuItem="no" onAfterSubmit="keepOpen" showStatusDialog="yes">
    <xsf:useScriptHandler></xsf:useScriptHandler>
    </xsf:submit>

    After:
    <xsf:submit caption="Submit" disableMenuItem="no" onAfterSubmit="close" showStatusDialog="yes">
    <xsf:webServiceAdapter wsdlUrl="http://k2megasrv/K2v3/InfoPathService/InfoPathService.asmx" queryAllowed="no" submitAllowed="yes">
    <xsf:operation name="SubmitInfoPathData" soapAction="http://www.sourcecode.co.za/webservices/InfoPathService/SubmitInfoPathData" serviceUrl="http://k2megasrv/K2v3/InfoPathService/InfoPathService.asmx">
    <xsf:input source="Submit.xml">
    <xsf:partFragment match="/dfs:myFields/dfs:dataFields/s0:SubmitInfoPathData/s0:pArrayData" replaceWith="/my:myFields"></xsf:partFragment>
    </xsf:input>
    </xsf:operation>
    </xsf:webServiceAdapter>
    </xsf:submit>

    This should give you a place to start looking at what is going on.
    Jason
    http://www.k2distillery.com/
  • 02-05-2006 04:49 AM In reply to

    Re: Preventing InfoPath Form Submission

    Thanks heaps for investigating and proving I'm not alone in experiencing this issue (or insane). :)

    I've got a series of enhancements to the existing project to play with so I'll try to claim a little time from them to follow on from your findings in the manifest.xsf

    Will post the results when I have them.

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