Add a button to infopath form to save it to its current submitted location

Hi,

I have an infopath form that is a content type in SP2007 form library. I submit this form programmaticaaly to the form library. I want to add a button to the form to perform save instead of using the save button in form as I want to close the form after saving I tried using the option of saving programmatically and adding this.activewindow.close but it gives error and when I searched I found that this function can't be called in save event so I want to add a button to save and close. I found some ideas of using xdocument but I couldn't get it into the code. I don't know if there is a directory missing or what so kindly advise how can I achieve this.

Thanks in advance.

October 5th, 2011 8:08am

add a button to your form and use action: rules and custom code, where you can do many actions. One is to submit your form and the other one is to close the form.

You may need to uncheck "Allow users to submit this form" in Tools - Submit Options" by menu.

For sure, you can also hide several other submit related default menus/buttons.

Free Windows Admin Tool Kit Click here and download it now
October 5th, 2011 3:16pm

Hi,

The form is already submitted to the library and I'm already using the method you mentioned. What I want is to add a button to save changes after the form has been submitted and if I used the submit option, it will give an error as the form already exists so kindly advise.

Thanks in advance.

October 9th, 2011 6:48am

You need to change the submit options to allow an overwrite if the file already exists.
Free Windows Admin Tool Kit Click here and download it now
October 12th, 2011 6:41am

Hi,

I think this won't help in my case as I have the file name as a combination of some fields that user can change during editing and so a new file will be created if I used the submit functionality so I want to save. I want to know how to use the Xdocument.

Thanks in advance

October 12th, 2011 7:01am

Simple answer to this one.... just add a button and add a rule that is 'When this button is clicked..." then choose 'Close Form'. if any data has changed in the form the user will be prompted to save the form first (it will default save to the location that it was opened from.

 

in my case i created a Change Request form that goes through a workflow of management approvals. once the item is apporved and the work is done, i require my team to open the form back up from the sharepoint approved library and add release date, completion code and any notes to the form then save it back to the list. adding the Save and Close button has helped a ton. otherwise they were tending to click submit again which would fire off an unnecasarry workflow again. i am no pro when it comes to infopath so this is the 'simple fix' :) im sure there is other ways to code it though.

 

cheers!

  • Proposed as answer by ThePCDoctorMD Wednesday, February 01, 2012 8:35 PM
Free Windows Admin Tool Kit Click here and download it now
February 1st, 2012 8:35pm

The way I tackle this is to put a field in my main data source for "File Name" (I don't actually display it anywhere on the form). I setup my submit data connection to use this file name and to overwrite existing files. I then add my Submit/Save button to the form and put some rules on it. I put in a rule to set the "File Name" field using whatever combination of fields needed, I also put a condition on this rule so that it only runs when the "File Name" field is blank (this stops the file name changing later). Then I put in a rule to run after to submit the form using the data connection. I usually also then put in a rule to close the form but that may or may not suit your needs.

This all means that the first time the user presses Save/Submit it will generate the file name, and save to library. On any subsequent presses, it will just save back to the library with the previously set file name.

If needed, it can often be helpful to add multiple save/submit buttons with variations on the rules above and use conditional formatting rules to only show the correct one at any given time based on other values in the form.

As a best practice I also go into the form options an untick the box to show InfoPath command on the ribbon or toolbar. This means users can only save/submit via your buttons and with your logic.

February 2nd, 2012 2:04pm

I know this thread is for 2007 and earlier, but the same problem exists in 2010, which is how I found this thread.  In 2010, the option to prompt for save on close is greyed out in the Rule Details dialog for browser-enabled forms.  If you're using InfoPath's form filler client that is a valid option though.

For my browser form I opted for the hidden filename field option that Steven described above.  If there is another way to do it in 2010, I haven't found it, so this was a great help.  Thanks Steven!

  • Edited by Ted Lewis Thursday, July 05, 2012 2:41 PM
Free Windows Admin Tool Kit Click here and download it now
July 5th, 2012 2:36pm

Didn't work for me, it actually says in InfoPath 2010 closing the form does not save it, you see the message when you select close form as an action. 

I have a different problem. My developers wrote some code to generate custom random file names so they could inject JS into the form. Problem is I can't expose the file name (forms library column is called Edit Link) in order to overwrite the record the user is editing. Before they added their code I was using the 'Account' column to name the file but now I don't know how to get the edit link value to update existing forms.

Any ideas?

July 24th, 2015 4:58pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics