Populate SharePoint List w/ InfoPath Form - InfoPath Dev
in

InfoPath Dev

Populate SharePoint List w/ InfoPath Form

Last post 04-03-2006 11:30 PM by Shanthi Reddy. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 03-24-2006 09:59 AM

    • sps232
    • Not Ranked
    • Joined on 03-22-2006
    • USA
    • Posts 2

    Populate SharePoint List w/ InfoPath Form

    Hi, I am new to InfoPath and this forum. I was wondering if anyone could help me out with using InfoPath to populate a list in SharePoint. I have found the info below, but wanted to ping the forum to see if there was a better way of doing this.

    http://groups.google.com/group/microsoft.public.infopath/browse_thread/thread/ebf9f9589f8be629/17a326c681e1a5c6?lnk=st&q=populate+list+in+sharepoint+from+infopath&rnum=1&hl=en#17a326c681e1a5c6

    From: [email protected] - view profile
    Date: Tues, Oct 11 2005 3:32 am
    Email: [email protected]
    Groups: microsoft.public.infopath
    Not yet ratedRating:
    show options


    Reply to Author | Forward | Print | Individual Message | Show original | Report Abuse | Find messages by this author


    After days and days of search, test, of suffering and crying, of tears,
    of great moment of hope and despair, I finally managed to find the
    solution to populate data from an Infopath form to a Sharepoint list
    (task list, for instance).

    First of all: the example you find under /_vti_bin/Lists.asmx is really
    really bad made. It's absolutly unclear. You don't need to specify an
    XSL schema, and the XML file asked is the same "Batch file" you create
    when you use UpdateListsItems using VB.NET. The lack of documentation
    about this is really a SHAME!! Now, lady and gentlemen, there's the
    final code:


    function CTRL54_5::OnClick(eventObj)
    {
    var objField1;
    objField1=XDocument.DOM.selectSingleNode("//my:myFields/my:Objet").text;
    XDocument.UI.Alert(objField1);


    var liste =
    XDocument.DOM.selectNodes("//my:myFields/my:group15/my:Activities");


    //The XML doc contains the same batch type as the VB.NET way of using
    UpdateListItems
    var xmlDoc = "";


    //The soap request is adapted from the example in /_vti_bin/Lists.asmx
    var soapRequest = "";


    //Using a xmlHttpRequest allow to don't bother about the precise
    formatting of the request, letting Infopath care about that.
    var xmlHttpRequest;


    //Here's our batch xml file. Very simple. Just add "Field" parameter
    to fill more fields (here's just an example)
    xmlDoc += "<Batch>";
    xmlDoc += "<Method ID='1' Cmd='New'>";
    xmlDoc += "<Field Name='Title'>Test</Field>";
    xmlDoc += "</Method>";
    xmlDoc += "</Batch>";


    //Prepare SOAP request. Notice that no schema is specified. The
    headers will come in the xmlHttpRequest object.
    soapRequest += "<?xml version='1.0' encoding='utf-8'?>";
    soapRequest += "<soap:Envelope
    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
    xmlns:xsd='http://www.w3.org/2001/XMLSchema'
    xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>";
    soapRequest += " <soap:Body>";
    soapRequest += " <UpdateListItems
    xmlns='http://schemas.microsoft.com/sharepoint/soap/'>";
    soapRequest += " <listName>test</listName>"; //Change here the
    name of the list to update
    soapRequest += " <updates>" + xmlDoc + "</updates>"; //Just
    specify your Batch xml variable created before
    soapRequest += " </UpdateListItems>";
    soapRequest += " </soap:Body>";
    soapRequest += "</soap:Envelope>";


    //objXMLHttp. Just a nice try&catch to deal with eventual problems.
    try
    {
    var xmlHttpRequest = new ActiveXObject("MSXML2.XMLHTTP.5.0");
    }
    catch(ex)
    {
    XDocument.UI.Alert("Could not create MSXML2.XMLHTTP.5.0 object.\r\n"
    + ex.number + " - " + ex.description);
    return false;
    }


    //Send datas to Sharepoint. Here we're specifying headers.
    Content-Length is not mandatory.
    xmlHttpRequest.open("POST",
    "http://yoursharepointserver/_vti_bin/Lists.asmx", false); //Just
    specify here the complete address of the list service
    xmlHttpRequest.setRequestHeader("Content-Type", "text/xml;
    charset=utf-8");
    xmlHttpRequest.setRequestHeader("Content-Length",1);
    xmlHttpRequest.setRequestHeader("SOAPAction",
    "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems");
    xmlHttpRequest.send(soapRequest);


    Thanks for any help you can give me on this.
  • 03-24-2006 12:19 PM In reply to

    Re: Populate SharePoint List w/ InfoPath Form

    Hi Cheri,

    Welcome to the forum. I am not sure what you need to do with the code you have posted.
    Here are two threads to get you started:

    http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=1999
    http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=1947

    Please post back if I don't answer your question right.
    Stephanie Cantwell / Test Manager
    Qdabra® Software / Streamline data gathering to turn process into knowledge

  • 03-24-2006 04:26 PM In reply to

    Re: Populate SharePoint List w/ InfoPath Form

    Hi Cheri,

    Check out this HowTo that I wrote explaining what I think is the best way to do this.
    http://infopathdev.com/howto/tutorials/default.aspx?i=7bc880f391b84ea9b3b45c6fbecc07c6

    This HowTo describes a technique which uses zero code which makes it extremely extensible and very straightfoward.
    If you have any questions about the HowTo, feel free to post back, but please continue this discussion
    on this thread:
    http://infopathdev.com/forums/topic.asp?TOPIC_ID=1757
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 03-30-2006 04:13 PM In reply to

    • sps232
    • Not Ranked
    • Joined on 03-22-2006
    • USA
    • Posts 2

    Re: Populate SharePoint List w/ InfoPath Form

    Thanks for your help. Matt, your how-to was great! I am a wanna be developer, so coding is still not the best path for me but I was able to change the templates you provided as needed. So for now, prob solved :~)

    If I have another question regarding whether there is such a thing as a repeating optional section...do I start another thread? (this is why i am still in the newbie area)

    Thank you both for your help!

    Cheri
  • 04-03-2006 11:30 PM In reply to

    Re: Populate SharePoint List w/ InfoPath Form

    Hi Cheri,
    Not sure if you posted else where. You can have a repeating optional section. Jus set minoccurs to be zero on the node that is repeating and you will be able to delete all sections mapped to that node from the view.

    Hope this helps!
    Shanthi Reddy
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.