locked
InfoPath form web part stops the close on submit RRS feed

  • Question

  • I have successfully published HTML browser enabled InfoPath 2010 forms to form libraries in SharePoint 2010. Users can navigate to the libraries and click new docuiment and fill out and submit forms, and the behavior of submit is as programmed in the form namely I have a concat rule for form name and chose action after submit to close the form with a success message.

    The problem I am seeing is a little abstract so stay with me while I explain. I'm hosting a number links to web part pages with the infopath web part on them. I use a links web part to aggrigate about 16 forms links on a single page. Users can successfully click on a link, are migrated to the web part page that has the form displayed in the infopath web part and all is well till they click the submit (on the ribbon, or custom button or whatever) The form does successfully get saved into the form library, but the form does not close.

    I need to make this process very simple for users without any training expended on the process. I'd like to shift focus to the previous web page, or close the form or something dramatic visually to show the user that they have completed the form fill out, and allow them to fill another form.

    Codebehind examples gratefully accepted!

    /Robin

     

     

    Sunday, September 5, 2010 9:12 PM

Answers

  • Absolutely no code needed for this.  You have several options:

    1. Why are you sending them to a custom page with a form web part?  What purpose is this serving?  Why aren't you just sending them right into the form itself within the Form Library?  What are you gaining from having a form web part on a custom page?  YOu are having to create that extra page, and you are making them experience non-default behavior, but then you're not taking advantage of all the great things you can do with the form web part.  You're just showing the form on a custom page and having them fill/submit, right?  You could just as easily have the form web part on the same page as the links list unless the forms are on different sites.  Anyway, if you just use the full URL to take them directly to the form so that it opens in the browser (not in a web part within a page), then you can simply set the Source attribute of the URL to the same page where they clicked the link...or send them somewhere else.  Go open one of your forms in the browser (not in the web part), copy the whole URL, then tweak the Source attribute to your liking.  Then, use the resulting URL in your links list.
    2. Why isn't the form closing?  The Form Web Part has a setting where you choose the behavior upon submit.  YOU tell it what to do.  It lets you open a new form, close, or leave it as-is.  Whatever you set in the form web part settings is what it should be doing.  If your submit button inside the form is set to close after submit, then the form should be going to a page that says "This form has been closed."  This is what it does when you close it inside a form web part.  Are you not seeing that?  If not, then what are you seeing?  Did you not set the form web part to close the form?  You can't change the page or anything, because the form is contained within a web part and is not controlled by the page URL at all.
    3. Simply create a new view in the form template and put a nice, formatted message on it saying that the form has been submitted successfully.  Then, set your submit button to simply switch views to this view instead of closing.  I have an example of this in my video, although it's not within a form web part.  I just do this anyway to let my users know what's going on.  Building Codeless Solutions with SharePoint and Office 2010

    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
    Monday, September 6, 2010 12:05 AM

All replies

  • Absolutely no code needed for this.  You have several options:

    1. Why are you sending them to a custom page with a form web part?  What purpose is this serving?  Why aren't you just sending them right into the form itself within the Form Library?  What are you gaining from having a form web part on a custom page?  YOu are having to create that extra page, and you are making them experience non-default behavior, but then you're not taking advantage of all the great things you can do with the form web part.  You're just showing the form on a custom page and having them fill/submit, right?  You could just as easily have the form web part on the same page as the links list unless the forms are on different sites.  Anyway, if you just use the full URL to take them directly to the form so that it opens in the browser (not in a web part within a page), then you can simply set the Source attribute of the URL to the same page where they clicked the link...or send them somewhere else.  Go open one of your forms in the browser (not in the web part), copy the whole URL, then tweak the Source attribute to your liking.  Then, use the resulting URL in your links list.
    2. Why isn't the form closing?  The Form Web Part has a setting where you choose the behavior upon submit.  YOU tell it what to do.  It lets you open a new form, close, or leave it as-is.  Whatever you set in the form web part settings is what it should be doing.  If your submit button inside the form is set to close after submit, then the form should be going to a page that says "This form has been closed."  This is what it does when you close it inside a form web part.  Are you not seeing that?  If not, then what are you seeing?  Did you not set the form web part to close the form?  You can't change the page or anything, because the form is contained within a web part and is not controlled by the page URL at all.
    3. Simply create a new view in the form template and put a nice, formatted message on it saying that the form has been submitted successfully.  Then, set your submit button to simply switch views to this view instead of closing.  I have an example of this in my video, although it's not within a form web part.  I just do this anyway to let my users know what's going on.  Building Codeless Solutions with SharePoint and Office 2010

    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
    Monday, September 6, 2010 12:05 AM
  • I also am having the same issue as Robin.

    The reason I am using a page to display the Infopath Web Part is because this is a public facing website and the company does not want anonymous users accessing the admin areas of the site.  Accessing the lists would qualify as an area that would be off limits to anonymous users. 

    Can someone explain why, even though I have set a rule to close the form in the InfoPath form and I don't have the option to change the Submit Behavior in the web part (because it is greyed out), that form does not close. 

    It would actually be nice to send the visitor to the site to the home page after they submitted the form or better yet send them back to the page they were on before the form page was opened. 

    Detailed "how to" would be greatly appreciated.  :-)

    Wednesday, October 20, 2010 8:01 PM
  • You can't send the user anywhere with the form, because the form is contained in a web part.  It does not have access to the browser session itself.
    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
    Wednesday, October 20, 2010 8:30 PM
  • A technique we have used to get around this is to have the form switch to a different view after the form has been submitted. This view just has some text like "Your form has been submitted for processing" and then a button with the label "Ok".

    In the button properties in Infopath, put the following into the id property "OKButton".

    Then add a content editor webpart onto the form and put the following javascript into the HTML text :-

    <script language="javascript">
    function InitWebpart()
    {
      //apply button click handler to InfoPath form OKButton
      $('input[buttonid="OKButton"').click(function() {
    		window.location.href = 'http://mytargetsite/';
        })
    }
    ExecuteOrDelayUntilScriptLoaded(InitWebpart, "sp.js");  
    </script>
    Then when the user clicks the Ok button, it redirects to your specified url.
    • Proposed as answer by Rakesh8698 Monday, June 27, 2016 9:33 PM
    Friday, August 10, 2012 2:59 AM
  • Change the button to SUBMIT type only by Infopath ->Select the button control>Control Properties>Action> change from Rules and code to just submit, save and publish.   Then go to webpart and it is not grayed out anymore.  You can change it and save webpart then go back in and switch the button type in infopath.
    Tuesday, September 17, 2013 10:27 PM