Code Behind InfoPath Form Published to SharePoint with URI formats

J

jogannon

With reference to the elegant solution described in the following:

http://enterprise-solutions.swits.n...form-into-word-2007-document-xslt-c-sharp.htm

I am able to publish an InfoPath form to a .msi and send it to another user,
with the document.docx and the transform.xsl files stored and the correct
path(s) noted in the code behind the "Convert" button. However, when I want
to publish this same form to a SharePoint (WSS) document library, I get the
proverbial error:

URI formats are not supported.
at System.IO.Path.NormalizePathFast(String path, Boolean fullCheck)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.File.InternalCopy(String sourceFileName, String
destFileName, Boolean overwrite)
at System.IO.File.Copy(String sourceFileName, String destFileName,
Boolean overwrite)
at ProdMgrWSRTemplate.FormCode.CTRL61_5_Clicked(Object sender,
ClickedEventArgs e) in E:\Documents and Settings\Administrator\My
Documents\Visual Studio
2005\Projects\ProdMgrWSRTemplate\ProdMgrWSRTemplate\FormCode.cs:line 46
at
Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
at
Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

I tried this originally using the url for another document library in the
same site. Then I went back to the physical path. Both produce the same
error. Ideally, I would like to be able to install and maintain this
solution as the SharePoint site collection admin, but it appears from what I
have read, that you must specify the user of the IIS server, underlying WSS,
having permissions to access these files where they are physically stored.

Any suggestions would be most grateful. Thanks,
 
S

S.Y.M. Wong-A-Ton

Hi Joe,

Did you read this article?
http://msdn.microsoft.com/msdnmag/issues/06/11/BasicInstincts/default.aspx
It describes how to generate documents on the server.

What you read about IIS and permissions is spot on. You would have to give
the identity under which SharePoint or Forms Services is running access to
the storage location of the files. This is typically the identity which the
application pool of the WSS site is running under.

But I think there is another way to do this. You could store the docx
template in a document library in SharePoint and then retrieve it using
either the SharePoint object model or the WebClient class. Once you've done
this, there is an overload of the Package.Open method that takes a Stream.
What you would have to do is convert the bytes from the docx that you
retrieved from SharePoint into a Stream and pass this to the Open method
instead of specifying a file path.

The disk where I stored my SharePoint VPCs crashed, so I do not have an
environment to test things out for you. So what I've written is all
theoretical right now, but you should be able to put it into practice. It's a
nice scenario, which I myself might try out and perhaps write about when I
get up and running again...
 
M

marly

Joe,

I ‘m using this as well and designed a pretty slick printout that converts
the InfoPath form to a PDF. I have about 100 field names on the form and I
went as far as to script changing the field names in the transform.xsl
automatically. It takes about 1 minute 30 seconds or so to go through them. I
use AutoIT and then programmed it to do a search/replace with it. It sure
beats the tediousness of changing the fields if you mess up your template or
want to change something.

I ran into a slight problem with rules and when I use “Set Condition†I get
“Some rules were not applied, unspecified error†when I try it.

Out of curiosity, on your form are you using any rules? Can put a Drop-Down
List Box on your form, set the list box entries to be 1 and then 2, go to
Rules, add rule, then in “Set Condition†put something like when field1 is
equal to 1 then display a message box that says, “hi†or try changing the
text of a text box. Run the form and then see if you get a “Some rules were
not applied, unspecified error†when you try it.

If I delete the data source with the transform.xsl I still get the problem.
There are still a few entries in the mainifest.xsf that point to the
transform.xsl, if I delete the data source, then go to the sixth line down to
where it starts off with <xsf:XDocumentClass and delete the schemas that were
added from the transform.xsl it works fine. Of course, now that I deleted the
data source I can’t convert my form to a PDF file. :(

If you can try putting on a Drop-Down List Box and putting in a rule (Don’t
forget to set the condition) and see if you get the same error, I’d greatly
appreciate it.

Thanks,

marly
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top