I have an InfoPath form published to a library... I need to create forms dynamically with siteuser as form name... I need to achieve it in Object Model... Can any of you help me on this...?
If you want to create form instances programmatically, I have done this recently with some relative ease.
As aforementioned, the XSN is a cab file. You need to use the
Microsoft.Deployment.Compression.Cab assemblies (which you can get here: http://wixtoolset.org/) to be able to read the cab file in memory (as opposed to saving it out to the file system first. Best to keep things in Streams in memory if at all possible).
Within the cab file, there is a file called template.xml which represents an empty form instance of that Form template.
Once you have that, you can then use standard XML techniques to populate fields in the
You will also have to set the form save location to the full URL of the library where the Form's content type has been added. I can't remember off hand what the name of that node in the XML is, but it's one of the first nodes in the file, in a section just before the
my namespace. You'll also need to generate a unique ID for the form (and this node is in the same section as before, the next node after the save URL), and this unique ID is just a GUID without the dashes, and in uppercase.
Once you've done all that, just use the SharePoint object model to write this completed XML to your library, using whatever name you want (just save with extension
.xml). Ensure you keep the 'mso' namespace elements at the top of the file as this tells SharePoint what XSN file to use to render your form.
InfoPath forms certainly can be programmatically built - that was one of the motivations of the change from the old office file formats (.doc, .xls etc) to the new (docx, xlsx etc)
These new formats are, in essence, cab files filled with XML-based data and manifests specifically designed to make object model manipulation easier.
Now, I don't exactly know what you want in entirety, but there are plenty of tutorials around to get started in creating forms programmatically. Such as this one from CodeProject
and, of course, there are many more via google
Is that what you meant, or was it something different you were after?
Why don't you have your form published as a content type in your site, and add a new document (item) with the user's specific name to that library out of this content type? At the end all content types in SharePoint inherit from the item content type, and you can easily add new item to SharePoint list programmatically if you already have your form deployed.
I haven't tried it yet, but my guess it should work