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...?
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?
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
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
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
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