One button to Print and Submit Form - InfoPath Dev
in

InfoPath Dev

One button to Print and Submit Form

Last post 04-15-2008 04:02 PM by Greg Collins. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 04-14-2008 11:26 AM

    One button to Print and Submit Form

    I want to create a "Submit" button that print the form and submits the data to a database at the same time but only if certain conditions are true.  I have created a button in the form with an "OnClick(Eventobj) using the code XDocument.PrintOut(); and XDocument.Submit(); but this method does not verify to the user that the data submitted to the databased succeeded or failed like the "Submit" button does on the toolbar.  I have intentionally disabled the submit and print funtions from the Toolbar to control them printing/submitting the form based on conditions. 
    If I create a "Submit" button and then click "Custom Submit using form code" 
    then click "Edit Form Code", it shows:
    
    function XDocument::OnSubmitRequest(eventObj)
    {
             // If the submit operation is successful, set
             // eventObj.ReturnStatus = true;
             // Write your code here
    } 
    
    What code do I need to write in order for it to submit the data to the 
    database and to print the form? And would this method verify if data was submitted to the database or not?
    I am using IP 2003 SP3.
    
    Thanks for any help
  • 04-15-2008 04:02 PM In reply to

    Re: One button to Print and Submit Form

    You've got the right idea, but you must do your own verification. This is typically done using a try/catch block.

    Please look up these methods in the documentation/help so that you can understand their requirements. For example, in order to use XDocument.Submit(), you must NOT disable submit in the toolbars. Here's a quote from the help files:

    Using the Submit method is similar to, but not exactly like, using the submit operation from the InfoPath user interface. Calling the Submit method simply performs the submit operation, but the submit operation must first be enabled for a form in design mode.

     

    Note  You can write a custom submit operation using the OnSubmitRequest event, and then you can programmatically call the event using the Submit method.

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