Add Sharepoint List Items with InfoPath - InfoPath Dev
in

InfoPath Dev

Add Sharepoint List Items with InfoPath

Last post 10-05-2010 11:52 AM by Patrick Halstead. 124 replies.
Page 6 of 9 (125 items) « First ... < Previous 4 5 6 7 8 Next > ... Last »
Sort Posts: Previous Next
  • 11-01-2006 11:44 AM In reply to

    Re: Add Sharepoint List Items with InfoPath

    Having experienced success in the basic method I am joining the ranks of persons that want to make a pretty and possibly conditionally formatted form and have it update a WSS list.

    I understand the 2ndary data idea. And have added fields.

    I got the submit button to have a couple of rules and managed to fill in my CAML with all one value and get it to submit. That is because I can only reference the Field node of the CAML with the rules and do not know how to specify the named field level using the tool provided with the RULES.

    If this is the CAML for example:

    <?xml version="1.0" encoding="UTF-8"?>
    <Batch OnError="Continue">
    <Method ID="1" Cmd="New">
    <Field Name="Title"></Field>
    <Field Name="Phone"></Field>
    <Field Name="Admin1"></Field>
    <Field Name="Domain1"></Field>
    </Method>
    </Batch>

    Do any of you know where I can find instructions on how to use the web scripting tool or the rules to stuff it so it looks like

    <?xml version="1.0" encoding="UTF-8"?>
    <Batch OnError="Continue">
    <Method ID="1" Cmd="New">
    <Field Name="Title">TheGuysTitle</Field>
    <Field Name="Phone">TheGuysPhone</Field>
    <Field Name="Admin1">TheGuysAdmin1</Field>
    <Field Name="Domain1">TheGuysDomain1</Field>
    </Method>
    </Batch>

    Instead of having one value assigned to every place - on the submit and before actually calling the web service??

    I so want to be able to do this but I am so new that I am not sure what path to take. It is all very interesting though..........
  • 11-07-2006 03:07 AM In reply to

    Re: Add Sharepoint List Items with InfoPath

    Hi All,

    This is my first post here. And the first thing I want to say is: "Matt Thank You Very Much for this thread and How-To article. I would never make it work without the article. But I'm joining to the group of people who would like to know how to make the form look a little bit pretier. Could anybody share his/her experience? Thank you very much!
  • 11-07-2006 05:15 AM In reply to

    Re: Add Sharepoint List Items with InfoPath

    Thanks Zamiran for casting your vote for more. We are energized and we are many LOL. Please Master Matt give us more.........

    :)

    L.
  • 11-07-2006 05:37 AM In reply to

    Re: Add Sharepoint List Items with InfoPath

    yonah, may be you can provide us with a little example of how to make forms look pretier? Or share the link/resource. Thank you!
  • 11-07-2006 09:30 AM In reply to

    • yonah
    • Not Ranked
    • Joined on 10-06-2006
    • USA
    • Posts 10

    Re: Add Sharepoint List Items with InfoPath

    Here is how I managed to get a pretty form to update sharepoint - again, thanks to matt for his original example, without which, I couldn't have gotten very far.

    First let me explain the process. What you are doing here is using the CAML as a template to create a record, which you then post to SharePoint's web service to add a new item.

    In Matt's example, you are binding the UI to the CAML so that as you update data in the UI, you are, in effect, modifying the CAML. To get this to work in the pretty version, all you need to do is write a script that inserts the data from your formfields into the CAML.

    Here is how I did it:

    1. I set up the Data Connections (to both the CAML and to SharePoint) as described in Matt's Article

    2. I laid-out my form in the 'Pretty' format.

    3. For each of my form fields, I assigned the same name as the corresponding field in the CAML - for example, if the field name is 'FirstName' in CAML, my form field was called 'FirstName'

    4. I changed the submit action to call a script.
    5. Using the script editor, I entered this code in the onSubmit method:

    var caml=XDocument.DataObjects["caml1"].DOM;
    var fields=caml.selectNodes("/Batch/Method/Field");



    for(i=0;i<fields.length;i++){

    fields.text=XDocument.DOM.selectSingleNode("//my:"+fields.attributes[0].text).text;

    }

    sharepoint=XDocument.DataAdapters["SharePoint"];
    sharepoint.Submit();
    eventObj.ReturnStatus=true;
    return;


    caml1 is my CAML file and SharePoint is my submit data source. Essentially what this code does is it gets the list of fields from the CAML, and then loops through them and attempts to set the CAML value to the form field with the same name. When the mapping is done, it posts to SharePoint.

    PLEASE NOTE: The only way that this will work is if the CAML field and the Corresponding form field have the exact same name.

    HTH,
    --Yonah
  • 11-07-2006 01:25 PM In reply to

    Re: Add Sharepoint List Items with InfoPath

    Eternally grateful to you oh wonderful Yonah. This is exactly the ticket. I figured it had something to do with an array like object. But never having been there.........

    L.
  • 11-07-2006 01:28 PM In reply to

    • yonah
    • Not Ranked
    • Joined on 10-06-2006
    • USA
    • Posts 10

    Re: Add Sharepoint List Items with InfoPath

    Good thing this Internet, eh?

    quote:
    Originally posted by Lalewicz

    Eternally grateful to you oh wonderful Yonah. This is exactly the ticket. I figured it had something to do with an array like object. But never having been there.........

    L.

  • 11-17-2006 02:20 AM In reply to

    Re: Add Sharepoint List Items with InfoPath

    Great tutorial!

    http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=3727 <-- I opened a new topic with a simular problem. Can someone help me out?
  • 11-17-2006 04:33 AM In reply to

    Re: Add Sharepoint List Items with InfoPath

    You are going to want to go the route of using fields outside of the caml repeating table, populate them and assign them to the caml using the method Yonah described of having identical names.

    I have found that this solves so many problems with the form.

    Unfortunately I am still struggling with getting the submit to actually work with the java script code behind that Yonah offered. I get the caml to populate with all of the like named fields, but the last step of the actual submission to the form chokes and throws the error that the onSubmistRequest didn't work. So far debug lines have not offered any info to me either. If anyone can offer a clue as to why the caml won't go into sharePoint at this time with the code from the link here I would be truely grateful. I have seen other posts on the internet complaining of similar issues but I cannot get my arms around the solution.
  • 11-17-2006 07:27 AM In reply to

    Re: Add Sharepoint List Items with InfoPath

    Oh happy day!! I figured out what I was doing wrong. I needed to submit to the web service in the script and not the SharePoint list. Doh! I was misreading the instructions and when Yonah in the posting was saying that they set up the data connections to SharePoint and the CAML I foolishly assumed they meant the sharePoint list and not the SharePoint web service. Whew.

    The hardest lessons are the ones best learned I guess. It works like a champion now. Thanks again to all for the wonderful help.
  • 11-17-2006 07:29 AM In reply to

    • yonah
    • Not Ranked
    • Joined on 10-06-2006
    • USA
    • Posts 10

    Re: Add Sharepoint List Items with InfoPath

    Lalewicz,

    A couple of 'gotchas':
    1. Wherever I refer to XDocument.DataObjects or XDocument.DataAdapters, the adapter name needs to match EXACTLY! I used a bad example, in that my DataAdapter is actually called SharePoint.

    If your Data Adapter is called 'SharePoint Submit' then use that.

    2. Make sure that you are posting to the correct Web Service. If you are on a subsite, you can't go tohttp://sharepoint/_vti_bin/.... but rather tohttp://sharepoint/subsite/_vti_bin...


    HTH
    quote:
    Originally posted by Lalewicz

    You are going to want to go the route of using fields outside of the caml repeating table, populate them and assign them to the caml using the method Yonah described of having identical names.

    I have found that this solves so many problems with the form.

    Unfortunately I am still struggling with getting the submit to actually work with the java script code behind that Yonah offered. I get the caml to populate with all of the like named fields, but the last step of the actual submission to the form chokes and throws the error that the onSubmistRequest didn't work. So far debug lines have not offered any info to me either. If anyone can offer a clue as to why the caml won't go into sharePoint at this time with the code from the link here I would be truely grateful. I have seen other posts on the internet complaining of similar issues but I cannot get my arms around the solution.


  • 11-22-2006 12:43 AM In reply to

    Re: Add Sharepoint List Items with InfoPath

    yonah, thank you very much!

    Great job!
  • 12-08-2006 01:27 PM In reply to

    • andrewR
    • Not Ranked
    • Joined on 12-08-2006
    • USA
    • Posts 1

    Re: Add Sharepoint List Items with InfoPath

    Like the others, this tutorial and this thread have been of tremendous help to me. Past three days, I've been tasked with learning InfoPath and SharePoint. I have to create an InfoPath Vacation Request form that once approved, will update a SharePoint list used as a Calendar view to show vacation scheduling.

    I am creating a 'Pretty form' and have followed the instructions closely. However, I am stuck with a jscript error. Here's the main part of my code for the onSubmit (AddPTOTemplate is my CAML file):

    var caml=XDocument.DataObjects["AddPTOTemplate"].DOM;
    var fields=caml.selectNodes("/Batch/Method/Field");

    for(i=0;i<fields.length;i++){

    fields.text=XDocument.DOM.selectSingleNode("//my:"+fields.attributes[0].text).text;
    }


    I get an error - Reference to undeclared namespace prefix: 'my'.

    Also, since this may become an issue later for me, my form contains DateTime controls which are using the Date Picker. My SharePoint list corresponding columns are of type DateTime also. I just thought I should mention this as I've seen others have issue with non-text/non-string data types.

    Any help appreciated.

    Andrew
  • 12-10-2006 06:59 PM In reply to

    Re: Add Sharepoint List Items with InfoPath

    I found an explanation on another newsgroup that may be useful to you. Try checkinghttp://www.cetix.de/OfficeNews/Thread258975-Problem_selecting_nodes.aspx

    Hope it helps.
  • 12-18-2006 03:02 PM In reply to

    Re: Add Sharepoint List Items with InfoPath

    Hi, I was wondering if anyone has figured out how to get this to work with a multiple rows. I've set the above code up in a repeating table however it doesn't seem to be working. I've tried it three separate ways. First, I used multiple methods in the caml however it simply duplicates the first row. Second, I removed the additional method from the caml but it only captures the first row. And lastly, I tried using the selectNodes method versus the selectSingleNode method to no avail. If anyone can steer me in the right direction, I would greatly appreciate it. Thanks!
    Shaun Nieves
    Sharepoint Manager
Page 6 of 9 (125 items) « First ... < Previous 4 5 6 7 8 Next > ... Last »
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.