Create new item in SP form library by code - InfoPath Dev
in

InfoPath Dev

Create new item in SP form library by code

Last post 02-08-2007 09:09 AM by Kun. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 02-07-2007 10:23 AM

    • Kun
    • Not Ranked
    • Joined on 11-07-2006
    • Posts 13

    Create new item in SP form library by code

    How can I write custom code that creates a new item in a Sharepoint form library? The only way I find out is to open an existing item via the object model and modify its nodes. But what can I do if no file exists?

    This is my current approach (that uses an existing file to create a new one):


    SPFile spTemplate = webSite.Folders[libraryName].Files[0];

    // reads the blank file into an xml document
    MemoryStream inStream = new MemoryStream(spTemplate.OpenBinary());
    XmlTextReader reader = new XmlTextReader(inStream);
    XmlDocument xd = new XmlDocument();
    xd.Load(reader);
    reader.Close();
    inStream.Close();

    XPathNavigator xpn = xd.CreateNavigator();

    xpn.SelectNode(...).SetValue(newValue);
  • 02-08-2007 09:03 AM In reply to

    Re: Create new item in SP form library by code

    Ofcource you need to have some schema, wich describes your template file. You may use your form library template to get this xml file instead webSite.Folders[libraryName].Files[0]...
    Best regards,
    Alexander Ekzarov
    Kyiv, Ukraine
    silverlightnet.blogspot.com
  • 02-08-2007 09:09 AM In reply to

    • Kun
    • Not Ranked
    • Joined on 11-07-2006
    • Posts 13

    Re: Create new item in SP form library by code

    That means I have to extract the .xsn file and use the schema definition in this cab file? Is there any code snippet how this works?
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.