I thought I'd add more to this topic to let it evolve further. The things that I am trying to achieve are this:
- The Form must have category specific security (as stated above)
- The user must be able to enter Rich-Text content in one of the controls (a bit tricky with a custom list and managed code)
- The user must be able to click on the link in SharePoint and it pull up the Form Document (we couldn't figure out how to do this with a custom list)
- all other validations are trivial in InfoPath
At the same time we are converting the clients existing data from Lotus Notes (Domino) into Sharepoint. The tool that our conversion specialist is using migrates to custom lists fine, but not form libraries (.xml). Also, the tool doesn't handle tables and images from rich text going into a custom list - so that is still needing attention going into Sharepoint (via managed code).
I have successfully created the piece within InfoPath that reads in the Custom List but I cannot figure out how to programmatically Save / Post each record in the list in an automated fashion to a Form Library. I keep running into dead ends. My approach is to fill in an infopath form for each custom list record and have infopath Submit or Save it.
Here's some code snippets I have so far (for conversion):
'---
'Code block of custom list retrieval left out for brevity
'---
Dim doc As XmlDocument = New XmlDocument
doc.LoadXml(Replace(xmldata.InnerXml, ControlChars.Lf & ControlChars.Lf, ""))
Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(doc.NameTable)
nsmgr.AddNamespace("z", "#RowsetSchema")
nsmgr.AddNamespace("rs", "urn:schemas-microsoft-com:rowset")
Dim node As XmlNode
Dim xs As XmlNodeList = doc.SelectNodes("/rs:data", nsmgr)
Dim xl As XmlNodeList = doc.SelectNodes("/rs:data/z:row", nsmgr)
For Each node In xl
For i As Integer = 0 To node.Attributes.Count - 1
Select Case node.Attributes(i).Name
Case "ows_Title"
thisXDocument.DOM.getElementsByTagName("my:title").Item(0).text = CheckForNothing(node.Attributes("ows_Title").Value)
Case Else
'additional left out for brevity
End Select
Next
'*** Here's what I thought would work
'--- it throws error (access is denied - huh?)
thisXDocument.DOM.save("http://someserver.abcd.com/SP%Database/SP%20Database%20Library/Forms/" + _
thisXDocument.DOM.getElementsByTagName("my:title").Item(0).text + ".xml")
'*** Here's my first attempt - no dice
'thisXDocument.Submit()
'*** I even tried with a Submit Data Connect to SP
'thisXDocument.DataObjects("Submit SharePoint Form Library").Query()
'*** I found this on the web - gives security error as well
'Dim HttpReq As New MSXML2.XMLHTTP40
'Dim strUrl As String = "http://someserver.abcd.com/SP%20Database/SP%20Database%20Library/Forms/"
'Dim strFileName As String = thisXDocument.DOM.getElementsByTagName("my:Title").Item(0).text + ".xml"
'HttpReq.open("HEAD", strUrl & strFileName, False)
'HttpReq.send()
''*** If XML Document was not found then Publish it
'If HttpReq.status = 404 Then
' HttpReq.open("PUT", strUrl & strFileName, False)
' HttpReq.send(thisXDocument.DOM.xml)
' If HttpReq.status = 200 Or HttpReq.status = 201 Then
' '*** Successful Posting
' End If
'End If
Next
Any help or input would be appreciated.