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 7 of 9 (125 items) « First ... < Previous 5 6 7 8 9 Next >
Sort Posts: Previous Next
  • 12-19-2006 03:07 PM In reply to

    Re: Add Sharepoint List Items with InfoPath

    I think I got it. I found a few others snippets of code and put this together.


    Dim numRows As Integer = thisXDocument.DOM.selectNodes("//my:myFields/my:Waste_Line_Items").length()
    'MsgBox(numRows, MsgBoxStyle.OKOnly)

    Dim i As Integer
    For i = 1 To numRows
    'Capture node values
    Dim TRACKNUM As String = thisXDocument.DOM.selectSingleNode("//my:myFields/my:Waste_Line_Items[" & i & "]/my:TRACKNUM").text
    'MsgBox(TRACKNUM, MsgBoxStyle.OKOnly)
    Dim LINENUM As String = thisXDocument.DOM.selectSingleNode("//my:myFields/my:Waste_Line_Items[" & i & "]/my:LINENUM").text
    'MsgBox(LINENUM, MsgBoxStyle.OKOnly)
    Dim PROFILENUM As String = thisXDocument.DOM.selectSingleNode("//my:myFields/my:Waste_Line_Items[" & i & "]/my:PROFILENUM").text
    'MsgBox(PROFILENUM, MsgBoxStyle.OKOnly)

    'Post node values to sps
    Dim incoming As New domain.Lists
    Dim cr As New System.Net.NetworkCredential("username", "password", "domain")
    incoming.Credentials = cr

    Dim doc As New XmlDocument
    Dim updates As XmlElement = doc.CreateElement("Batch")

    updates.InnerXml = "<Method ID='1' Cmd='New'><Field Name='TRACKNUM'>" + TRACKNUM + _
    "</Field><Field Name='LINENUM'>" + LINENUM + _
    "</Field><Field Name='PROFILENUM'>" + PROFILENUM + _
    "</Field></Method>"
    incoming.UpdateListItems("{list id}", updates)
    Next

    End Sub


    Hope this helps anyone else who was having a hard time.
    Shaun Nieves
    Sharepoint Manager
  • 12-22-2006 01:13 AM In reply to

    Re: Add Sharepoint List Items with InfoPath

    Trying to recreate this tutorial on Sharepoint 2007.

    Tried several times and also tried to use different walkarounds.

    Dut I get the followung message:

    The SOAP response indicates that an error occurred on the server:

    Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.
    <detail><errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">Value does not fall within the expected range.</errorstring></detail>

    My XML file is the following

    <?xml version="1.0" encoding="UTF-8"?>
    <Batch OnError="Continue">
    <Method ID="1" Cmd="New">
    <Field Name="Title"></Field>
    <Field Name="Last_Name"></Field>
    <Field Name="First_Name"></Field>
    <Field Name="Source"></Field>
    <Field Name="Owner"></Field>
    </Method>
    </Batch>

    One drop down list and other text list

    I will be greatful for help.
  • 12-22-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

    Dreamer,

    First, let me state that I haven't yet worked with 07' so I can't tell you if this is 07' specific.

    The two things I would check are:

    1. If this is a lookup, make sure you use the 'ID' field as the value
    2. If you are only uploading a subset of your list columns, and are missing some 'required' columns, it will not let you post.

    HTH.
    --Yonah


    quote:
    Originally posted by dreamer777

    Trying to recreate this tutorial on Sharepoint 2007.

    Tried several times and also tried to use different walkarounds.

    Dut I get the followung message:

    The SOAP response indicates that an error occurred on the server:

    Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.
    <detail><errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">Value does not fall within the expected range.</errorstring></detail>

    My XML file is the following

    <?xml version="1.0" encoding="UTF-8"?>
    <Batch OnError="Continue">
    <Method ID="1" Cmd="New">
    <Field Name="Title"></Field>
    <Field Name="Last_Name"></Field>
    <Field Name="First_Name"></Field>
    <Field Name="Source"></Field>
    <Field Name="Owner"></Field>
    </Method>
    </Batch>

    One drop down list and other text list

    I will be greatful for help.

  • 01-23-2007 07:52 AM In reply to

    Re: Add Sharepoint List Items with InfoPath

    hi,I have encountered problems implementing this article into Infopath 2007. Really, I've not idea on where the problem is, because there is no error when I send data to the web service. As dreamer says, I've tried several times using diferent walkarounds, and there's no way.
    This is my CAML:

    <?xml version="1.0" encoding="UTF-8"?>
    <Batch OnError="Continue">
    <Method ID="1" Cmd="New">
    <Field Name="Title"></Field>
    <Field Name="Esto%5Fx0020%5Fes%5Fx0020%5FProbar"></Field>
    <Field Name="Esto%5Fx0020%5FTambien"></Field>
    </Method>
    </Batch>

    Sorry for my english ;)
  • 02-20-2007 08:15 AM In reply to

    • c5rlh
    • Not Ranked
    • Joined on 05-12-2006
    • Posts 4

    Re: Add Sharepoint List Items with InfoPath

    Hi there,

    I'm sure I'm missing something here, but rather than adding a new record can this method be used to edit an existing record?

    I've got a couple of forms I've designed where I'm pulling a record from a list and I want to write back a value.

    for Example: I've got a holiday request form for our company where each person has an allocated amount of days to take per year. Each time someone makes a request, I want their record to have it's holiday days reduced by the number requested.

    I get the adding records and it works a treat, but I'm new to this web service stuff, and I just can't get my head round how I could get this to work.

    Can you give me a few Pointers on where to go.

    The list item's ID number is stored in the form as the user select's their name so I was hoping to update based on that figure.

    Many, many thanks in advance.

    Russ
  • 02-21-2007 10:18 AM In reply to

    Re: Add Sharepoint List Items with InfoPath

    I used a field to be my primary indicator whether or not a record should be inserted or updated. Here's the code. (In vb.net)


    If TrackingID.ToString <> "" Then
    updates.InnerXml = "<Method ID='1' Cmd='Update'><Field Name='ProfileNumber'>" + PROFILENUM + _
    "</Field><Field Name='InboundNumber'>" + InboundNumber + _
    "</Field><Field Name='TrackingNumber'>" + TRACKNUM + _
    "</Field><Field Name='Material'>" + MATERIAL + _
    "</Field><Field Name='ActualMaterial'>" + ACTUAL + _
    "</Field><Field Name='Unit'>" + LOCUNIT + _
    "</Field><Field Name='ContainerType'>" + CONTTYP + _
    "</Field><Field Name='Size'>" + SIZE + _
    "</Field><Field Name='Weight'>" + WEIGHT + _
    "</Field><Field Name='Action'>" + Action + _
    "</Field><Field Name='DateOfAction'>" + INCOMINGDATE + _
    "</Field><Field Name = 'Active'>" + ACTIVE + _
    "</Field><Field Name = 'ID'>" + TrackingID + _
    "</Field></Method>"
    incoming.UpdateListItems("{9D39C54C-ABBB-4E79-A3DA-A781ADB09DF3}", updates)

    ElseIf TrackingID.ToString = "" Then
    updates.InnerXml = "<Method ID='1' Cmd='New'><Field Name='ProfileNumber'>" + PROFILENUM + _
    "</Field><Field Name='InboundNumber'>" + InboundNumber + _
    "</Field><Field Name='TrackingNumber'>" + TRACKNUM + _
    "</Field><Field Name='Material'>" + MATERIAL + _
    "</Field><Field Name='ActualMaterial'>" + ACTUAL + _
    "</Field><Field Name='Unit'>" + LOCUNIT + _
    "</Field><Field Name='ContainerType'>" + CONTTYP + _
    "</Field><Field Name='Size'>" + SIZE + _
    "</Field><Field Name='Weight'>" + WEIGHT + _
    "</Field><Field Name='Action'>" + Action + _
    "</Field><Field Name='DateOfAction'>" + INCOMINGDATE + _
    "</Field></Method>"
    incoming.UpdateListItems("{9D39C54C-ABBB-4E79-A3DA-A781ADB09DF3}", updates)
    End If


    Before this is executed, you need to run the following code in an onload event. This assisgns the unique record ID to the repeating table row. It should be easy to modify if you're not using a repeating table though.


    Dim numRows As Integer = thisXDocument.DOM.selectNodes("//my:myFields/my:Waste_Line_Items").length()
    'MsgBox(numRows, MsgBoxStyle.Critical)
    Dim i As Integer

    For i = 1 To numRows
    'MsgBox("Test", MsgBoxStyle.Critical)
    Dim dataDOM As DOMDocument50 = thisXDocument.DataObjects("IncomingCapture").DOM
    dataDOM.setProperty("SelectionNamespaces", "xmlns:dfs=""http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"" xmlns:my=""http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-12-12T22-07-01"" ")

    'Grabs the tracking number from the repeating section
    Dim trackNum As String = thisXDocument.DOM.selectSingleNode("//my:myFields/my:Waste_Line_Items[" & i & "]/my:TRACKNUM").text
    'MsgBox(trackNum, MsgBoxStyle.Critical)

    'Grabs the ID from the secondary datasource and filters the result
    Dim id As String = thisXDocument.GetDOM("IncomingCapture").selectSingleNode("/dfs:myFields/dfs:dataFields/dfs:InboundData/@ID[../@TRACKNUM ='" & trackNum & "']").text
    'MsgBox(id, MsgBoxStyle.Critical)

    'Assigns the ID to a field in the repeating section
    thisXDocument.DOM.selectSingleNode("//my:myFields/my:Waste_Line_Items[" & i & "]/my:INCID").text = id
    Next


    Hope this helps.
    Shaun Nieves
    Sharepoint Manager
  • 02-26-2007 01:50 PM In reply to

    Re: Add Sharepoint List Items with InfoPath

    Hi everyone!

    I've followed the instructions to the best of my ability three times now and still get the same results. I must really be missing something!

    When I preview the form, it looks like this:



    Notice in the screenshot above that there isn't any place to put the information for the new contact (or am I missing something).

    If I hit the submit button, I get the following error:

    The form definition (.xsf) file has an invalid mapping from the document to the submit Web service.

    Any help is apprecitated! Thanks!
  • 02-26-2007 01:52 PM In reply to

    Re: Add Sharepoint List Items with InfoPath

    Oh, my CAML looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <Batch OnError="Continue">
    <Method ID="1" Cmd="New">
    <Field Name="Title">LastName</Field>
    <Field Name="FirstName">FirstName</Field>
    <Field Name="Email">Email</Field>
    <Field Name="WorkPhone">Phone</Field>
    </Method>
    </Batch>
  • 02-26-2007 02:12 PM In reply to

    Re: Add Sharepoint List Items with InfoPath

    I've also tried the CAML from the instructions with the same results:

    <?xml version="1.0" encoding="UTF-8"?>
    <Batch OnError="Continue">
    <Method ID="1" Cmd="New">
    <Field Name="Title"></Field>
    <Field Name="FirstName"></Field>
    <Field Name="Email"></Field>
    <Field Name="WorkPhone"></Field>
    </Method>
    </Batch>
  • 03-04-2007 10:24 PM In reply to

    Re: Add Sharepoint List Items with InfoPath

    Hi Matt,

    Fantastic forum, your information has been very helpful.

    You replied to user Christoph on the 7th April 06 regarding his need to specify different controls for different fields within the same form advising that another secodary data source would be required with additional code required for the submit button. I am in the same situation as Christoph and cannot figure out how to accomplish this. Are you able to assist further?

    Cheers

  • 03-30-2007 11:54 AM In reply to

    Re: Add Sharepoint List Items with InfoPath

    I am getting same thing. InfoPath reports Submit was successful but I do not see anything in my list.

    I am using Infopath 2007 and Moss 2007 Enterprise

    Here is my CAML
    <?xml version="1.0" encoding="UTF-8"?>
    <Batch OnError="Continue">
    <Method ID="1" Cmd="New">
    <Field Name="Title"></Field>
    <Field Name="FirstName"></Field>
    <Field Name="LastName"></Field>
    <Field Name="JobTitle"></Field>
    </Method>
    </Batch>

    I was able to use this code in CAMLBuilder and it added an item to the list.

    I am not sure what I am doing wrong.

    I looked at each field in the list url down in the modify settings and they were spelled exactly as in my CAML file
  • 04-24-2007 08:34 AM In reply to

    Re: Add Sharepoint List Items with InfoPath

    Hi Matt

    Thanks for the great tutorial..your info will save me a lot of hassle, as without the 'submit to a list'  I was previously submitting to a forms library then using SQL triggers to copy the relevant data from the form library to the list - not ideal to say the least...

    …that’s if I can get it to work that is…I'm a bit stuck on the last step of the guide though. When I click the button to submit the form, it comes back with the following error:-

    InfoPath cannot submit the form.
    An error occurred while the form was being submitted.
    The SOAP response indicates that an error occurred on the server:

    Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.
    <detail><errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">There is no Web named "/sites/xxx".</errorstring></detail>

    Searching Google & Microsoft draws a blank.

    I've check the GUID string and that's correct - I even changed it as a test and it comes back with a different error...I’m running MOSS 2007 with all the latest service packs on the server and XP, InfoPath 2007 again with all the service packs on the client

    Any help with this one appreciated.... 

    Thanks

  • 04-25-2007 03:11 AM In reply to

    Re: Add Sharepoint List Items with InfoPath

    gallowgate:

    Hi Matt

    Thanks for the great tutorial..your info will save me a lot of hassle, as without the 'submit to a list'  I was previously submitting to a forms library then using SQL triggers to copy the relevant data from the form library to the list - not ideal to say the least...

    …that’s if I can get it to work that is…I'm a bit stuck on the last step of the guide though. When I click the button to submit the form, it comes back with the following error:-

    InfoPath cannot submit the form.
    An error occurred while the form was being submitted.
    The SOAP response indicates that an error occurred on the server:

    Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.
    <detail><errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">There is no Web named "/sites/xxx".</errorstring></detail>

    Searching Google & Microsoft draws a blank.

    I've check the GUID string and that's correct - I even changed it as a test and it comes back with a different error...I’m running MOSS 2007 with all the latest service packs on the server and XP, InfoPath 2007 again with all the service packs on the client

    Any help with this one appreciated.... 

    Thanks

     

    ...Sorted this now....I was selecting the list service of the root site instead of the sub site......

     

  • 10-05-2007 10:57 AM In reply to

    Re: Add Sharepoint List Items with InfoPath

    Hi Matt,

    I read your article on how to add Sharepoint List Items with InfoPath, but I got stuck at one point.

    In the section "Add the connection to the SharePoint web service:"  I cannot find the "data source button" on step 7 (this is to update the s0:updates parameter). I am running IP with SP2. Is there something that I am missing?

     

  • 10-05-2007 11:04 AM In reply to

    Re: Add Sharepoint List Items with InfoPath

    Let me correct myself, I do have the button. However, from the Data Source drop down menu I do not have the "Add List Item Template" option.

Page 7 of 9 (125 items) « First ... < Previous 5 6 7 8 9 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.