4

Salvete! I have an InfoPath-based content-type. I also created a forms library in several subsites that each use this content-type.

Now, I need to fix my InfoPath content-type form so that it gets submitted to its own form library. Right now, when it gets submitted, all the submitted forms go to one particular library that I made for testing - which is neat, but I need it to remain in the subsite.

So, my question is, how do I make the form get submitted to its own library? Since each site has a form library, I want the submitted forms to get saved there.

I don't see any way to set the url for the submitted form to anything but a static full url; but maybe I am missing something...

[update] I have discovered, too, that if you "save" a form instead of "submit" the form, it does, indeed, go into the SAME library, instead of getting submitted to the library specified in the data connection. Maybe there is a workaround to prevent the "submit" action, and allow the user to only "save" the form...

3
  • Please post different questions into different posts since changing the original question confuses both the answering and looking for answers folks Commented Oct 18, 2012 at 5:42
  • Sorry; I thought I was fixing my title to better reflect the single question I explained in the text.
    – bgmCoder
    Commented Oct 18, 2012 at 14:22
  • Also, I never asked in this question about how to create two infopath-based content types, which you have so generously (thanks, but that's not what I wanted) supplied. I stated in my question that I had already done that.
    – bgmCoder
    Commented Oct 18, 2012 at 15:03

3 Answers 3

3

Can be done with a small amount of code.

http://blogs.msdn.com/b/infopath/archive/2006/11/08/submitting-to-this-document-library.aspx

http://www.bizsupportonline.net/blog/2010/01/2-ways-retrieve-sharepoint-site-collection-infopath-browser-form/

I generally provide links to users to initiate opening a form (provided it's IPFS), so I can control those initiation parameters with each link. They usually find it easier to use the links anyway, rather than opening the library and hitting New Whateverform.

4
  • Thanks! I have already visited the first link - which looks promising. Have you tried this, yourself? I've never written any code for an InfoPath submission before. When you say you "provide links", do you mean you are sending url parameters to the forms?
    – bgmCoder
    Commented Oct 18, 2012 at 17:48
  • Well, I haven't generally needed to do that, but when I say "Provide links", I mean that the way users would start a new form is to click a link I make for them in the lefthand navigation which starts it from FormServer.aspx, like so: my.site.com/subsite/_layouts/FormServer.aspx?XsnLocation=https:/… Commented Oct 18, 2012 at 19:42
  • Additional parameters (such as declaring in advance which form type this is) would be supplied as GET parameters after DefaultItemOpen and then parsed using the Form Loading event code referred to in the second link. Commented Oct 18, 2012 at 19:48
  • One should avoid coding due to a related maintenance hassle. I do not understand what is the need in having a submit data connection and why it should be done through coding. What's wrong with using a common template part (.xtp) file to create templates with its own submit data connections codelessly? Commented Oct 19, 2012 at 16:31
0

This can, indeed, be achieved via code-behind. Sharepoint only allows you to submit to a static URL. However, you can submit to a dynamic url (of which, the current library is a sort of dynamic url) using code-behind.

Look here and here for code to achieve this.

If you want to use code-behind in your form, there are a few things you need to do first. Make sure that:

  • Sandboxing is enabled in SCA (it prevents malicious code from affecting your server)
  • You have signed your form in InfoPath (this requires your certificate to be designated for "code-signing" rather than "server authentication" - you can create a self-signed certificate for dev purposes, but it is only good for a month, and is not automatically accepted by the user's browser
  • Publish as an administrator-approved template. This will prompt you to save the form as a file on your local drive.
  • After you save it, note the file location, and go to SCA in "General Application Settings" and find "Manage Form Templates" in the InfoPath area. Upload the template you just saved. Then, in SCA, in the dropdown menu of your uploaded form, select "Activate to a Site Collection" and send it to your site.
  • You might have to go and add this content-type as a new type in your forms libraries. If you previously tried to publish the form directly from InfoPath, SCA may tack a "1" onto the file name and treat it as a new content type.
2
  • As I noted before in my answer, there is no need to digitally sign code or use administrator approved forms if you convert submit data connection to UDCX connection file stored in sharepoint data connection library of the same sharepoint site collection. Also has not you duped the previous answer which answered your question ? Commented Oct 25, 2012 at 5:28
  • This is the full answer, in my opinion - the one I would have hoped to receive (the "peers" did not approve my edit to the other answer). The code-signing is necessary for code-behind in the form. As I said in my question, I don't want to use a static full url for the data connection. By using code, I only need the data connection file to fulfill the sharepoint requirement, but in fact it never really gets used. The code-behind allows the content-type to submit to ANY library that hosts the content-type - without having to create another data connection.
    – bgmCoder
    Commented Oct 25, 2012 at 14:10
0

Revised answer:

The scalable and codeless solution is to use a template part (.xtp) file for creating multiple templates each with its own submit data connection to its own library instead of (complete) one content type template per multiple libraries.
Or to avoid Submit data connections and use a content type template for saving Infopath XML data forms based on it.

Update:

One can disable Submit in Form Options in Infopath Designer 2010 though by default it is not even enabled and I do not understand why to enable it if using content type

Form Options - Submit is not configured...

Fig.1. Form Options - Submit is not configured...

Submit Options - Allow Users to submit this form

Fig.2. Submit Options - Allow Users to submit this form

I proposed above the codeless way to submit a form to its own sharepoint library and it is imperative to avoid coding which incurs a maintenance hell.

Concerning the article of changing Submit data connection URL which is possible only through code, it states:

  • "Set the Security Level of the form to Full Trust and sign the form template with a digital certificate"

This incurs the necessity of administrator approval of forms what is quite inconvenient and straight impossible in Sharepoint Online (Office 365).
Meanwhile it (Full Trust and code digital signing) is not necessary if to convert "Main submit" data connection to UDCX data connection file stored in data connection library of the same sharepoint site collection.

6
  • I think you missed my point, Mr. Vanin (thanks for being so ready to answer!). I have already done this, and that is how I, myself have two libraries, each with the ability to generate my infopath-based content-type - just like in your pictures. However, MY point is that I don't want the forms submitted to the library specified in the data connection. I want them submitted to their OWN libraries to which I assigned the content types. Clear as mud?
    – bgmCoder
    Commented Oct 18, 2012 at 5:08
  • Actually, the forms will "save" into their own libraries, but they won't "submit" unless you specify that in the data connection.
    – bgmCoder
    Commented Oct 18, 2012 at 5:22
  • Sorry, I do not understand. In my description there is no data connection whatsoever?! There is an XSN form template published as content type and form/document libraries using this content type for creating/editing XML data forms on the basis of that XSN template (content type). When you submit Infopath XML data forms created/edited on the basis of that content type an XML data form goes to its (different and in different sites) library, resp. Commented Oct 18, 2012 at 5:23
  • If you remove the ability to submit the form, then you don't need a data connection, and you instead will "save" the form. I think that this idea is one, simple solution - which you have, indeed stated in your long answer.
    – bgmCoder
    Commented Oct 18, 2012 at 14:54
  • The idea was to cover the maximum of possibilities in a guessing game. I had no idea that you havd configured Submit data connection and the term definitions used in Infopath questions are quite unexpected, in my experience. Also, there is no need to remove anything you never created in first place (it does not appear all by itself)! Commented Oct 18, 2012 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.