Opening a readonly file from sharepoint document library

A

AJL

I'm using the InfoPath FormControl from a windows form application. I have
no problem using FormControl1.Open to open an existing form housed in
sharepoint if the form is checked out. But FormControl1.Open will not open
an existing form if the form is not already checked out (Read Only). I
receive the error:

InfoPath cannot open the following file: http://xxx
The form is marked as read-only.

I thought that if I recreated the template with a read-only default view
that this might fix the problem but it did not.

Any suggestions on how to view an infopath file hosted in sharepoint without
checking it out?

Thanks,

AJL
 
A

AJL

Well, here's how I've solved the problem. Other suggestions are welcome. I
use an http web request to download the xml form. I have the template stored
locally so I avoid that problem. The trick is to append a parameter to the
end of the url so the form server does not try and take over control. The
code is below. In order to truly make the form look read-only I will also
have to create a read-only view and switch to it as well. Again, this avoids
needing to check out a form housed in sharepoint in order just to view it.

Dim request As HttpWebRequest
Dim response As HttpWebResponse
Dim s As Stream
Dim xmldoc As New XmlDocument
Dim bytes As Byte()

request = WebRequest.Create(filePath & "?noredirect=true")
request.Credentials = CredentialCache.DefaultCredentials
request.PreAuthenticate = True

response = request.GetResponse
s = response.GetResponseStream

xmldoc.Load(s)
bytes = Encoding.UTF8.GetBytes(xmldoc.OuterXml)

'load the byte array into the memory stream
memStream.Write(bytes, 0, bytes.Length)

FormControl1.NewFromFormTemplate(template, memStream,
XmlFormOpenMode.ReadOnly)

memStream.Close()
 

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