Submit form with confirmation (rule or code) - InfoPath Dev
in

InfoPath Dev

Submit form with confirmation (rule or code)

Last post 08-04-2010 10:34 PM by jayanaveen. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 10-25-2006 11:35 AM

    • Guapo
    • Not Ranked
    • Joined on 10-25-2006
    • Portugal
    • Posts 2

    Submit form with confirmation (rule or code)

    Hello all

    I have created a infopath 2003 sp2 template that can be submited to 3 sharepoint libraries (Wss v2). I have 3 buttons with rules using 3 different submit data connections.
    Using the button properties and rules, it works great, BUT, i require that a confirmation dialog to appear before proceeding with the submission.

    1) Is there a way using rules?

    I already tried a different approach using code.
    By using the following code i can ask the confimation, but i can not "trigger" the
    submit data connections.

    XDocument.UI.Confirm("Do you want to submit this request?",1);



    2) Can i "trigger" the submit to wss form libs data connections from code?

    So i went off again and found this KB article on submitting via http using jscript:http://support.microsoft.com/kb/826993

    If use the submit from File Menu, it only allows to continue if validations are OK, BUT, using a button to run the code it does NOT validate "can not be blank fields, etc".

    3) How can i trigger validation, and get a result ( OK or failed) using jscript, so that i can prevent the submit action?

    Thank you very much. So far this is the best Inpath knoledge center I know.
    
    										    
    									    
  • 10-25-2006 02:51 PM In reply to

    Re: Submit form with confirmation (rule or code)

    It is my understanding that you do not have to trigger data validation that is built into the XML schema/ XSL. I think what you are trying to do is check to see if any of the validations have been broken before you try to submit to SharePoint so that the error message will not popup.

    To do this, try this code (I haven't done JScript in a while, so it might be off a little):

    if( XDocument.Errors.Count > 0 )
    {
    XDocument.UI.Alert( "There are errors in the form, please correct these and try again." );

    // Return the OnClick event handler because we do not want to submit to the datat connection.
    return;
    }


    I hope this helps!
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 10-26-2006 04:59 AM In reply to

    • Guapo
    • Not Ranked
    • Joined on 10-25-2006
    • Portugal
    • Posts 2

    Re: Submit form with confirmation (rule or code)

    Thanks for your fast reply Matt.

    That code resolves my 3) question.

    I will explain better my introduction to 3) question: I have putted the KB article code on the "onClick" function of a button. The user can click the button, even if there are red asteriscs and red boxed fields, and the code would not validate that and save the form anyway.

    With the code you provided i can now cancel the submission with the same message that appears using the data connection submission.

    Back to my 1) problem, if i have a button with associated rules and code, the rules run first, then the code. How can i set the other way around?
    (I would code a confirmation dialog, and use the submit data connection rule)
  • 11-28-2008 08:06 AM In reply to

    Re: Submit form with confirmation (rule or code)

    Hello Matt, I've been trying to do this for quite a while,this is the first time I code infopath. So if you can please give me a detailed tutorial on how to do this would be greatly appreciated. I need details on where to place the code (the whole thing). I got a project to deliver in the next couple of days and your guidance will be great.

     

    Thanks,

    Soldier

  • 11-28-2008 09:43 PM In reply to

    • Anuma
    • Top 25 Contributor
      Female
    • Joined on 07-20-2005
    • India
    • Posts 525

    Re: Submit form with confirmation (rule or code)

    Hello,

     

    You can do this by using rules.

     
    1. Double click on the button.
    2. Add Rule to submit data connection.
    3. Add second rule to show “Successful” message.
      1. Click on the Rules.
      2. Click on Add Action button.
      3. Select “Show a dialogue box Message” from action dropdown.
      4. Enter you message and Click on ok.
     

    Are you submitting the form to SharePoint or any other?

     

    Anuma Chinthapalli /
    http://www.GGKTech.com
  • 11-29-2008 10:12 AM In reply to

    Re: Submit form with confirmation (rule or code)

     Hello Anuma, I appreciate your taking the initiative to help out in this matter.To answer your question, the infopath submits to a Sharepoint Form Library.But the answer you gave me I'm already aware of.My case requires that I need to add some code into the form to make it pop up a prompt message or alert asking me to confirm the click event before submitting the filled form ("Are you sure you want to submit?") . I can't seem to be able to find my way through that.any visual or detailed tutorial will be much appreciated... Thanks,

    Soldier

  • 11-30-2008 03:36 AM In reply to

    Re: Submit form with confirmation (rule or code)

    What type of code do you plan to use (C#, VB...)?  Are you using InfoPath 2003 and require using JScript or VBScript?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-01-2008 04:24 AM In reply to

    Re: Submit form with confirmation (rule or code)

    Hi Jimmy thanks for the response,

     

    Im using Infopath 2007, I intend to use C# and require to use JScript for prompts and dialog boxes. I need to add also if there's a way to have those features workable in Forms Services (web browser-enabled). I think these features do not work for some compatibility reasons. Note that the form is associated in sharepoint library and gets data from lists uploaded into the sharepoint portal as well...

     

    Thanks

  • 08-24-2009 08:59 PM In reply to

    Re: Submit form with confirmation (rule or code)

    Hi,

     Anyone got the solution for this? I need to execute the script before the rules. I'm using InfoPath 2003.

    The confirmation message "XDocument.UI.Confirm("Do you want to submit this request?",1);" shows after the rules executed. But I require it in reverse.

    - Sanrajesh

  • 08-04-2010 10:34 PM In reply to

    Re: Submit form with confirmation (rule or code)

    Hi,

    while executing a infopath form, always rules associated to the control will trriger first then the functions will be executed. 

     To submit infopath forn using vbscript . try the following code

    XDocument.DataAdapters("Data Connection Name").Submit

     

    Regards,

    Naveen.

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