Welcome to MSDN Blogs Sign in | Join | Help

InfoPath Team Blog

Tips and tricks to get the most out of Microsoft InfoPath

News

  • For questions, comments, and feedback please use the public newsgroup: microsoft.public.infopath
    This is provided "AS IS" with no warranties, and confers no rights. Use of included script samples and forms are subject to the terms specified in the Terms of Use.
Submitting to a SharePoint List

As you know, submitting to a Microsoft Windows SharePoint form library from an InfoPath form is quite simple: just add a “submit” type of data connection to InfoPath and away you go. However, submitting to a SharePoint List is another matter. In this post, we will take a look at the steps necessary to enable this functionality.

Step 1: Create the list

1. Create a new custom list named: MyContacts
2. From the Settings button choose List Settings
3. Click Create Column
4. Add the following columns/data types:

  • FirstName, Single line of text
  • LastName, Single line of text
  • Email, Single line of text
  • Phone, Single line of text

The next step is to create a Collaborative Application Markup Language (CAML) template that contains the same XML nodes as the columns we added to our list – this will be used as a secondary data connection in the InfoPath Form Template.

Step 2: Create the CAML template

1. Launch Notepad (or any text editor)
2. Copy and paste the following code to the Notepad document:

<?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="Email"></Field>
        <Field Name="Phone"></Field>
    </Method>
</Batch>

3. Save this as: Add List Item Template.xml

 

Step 3: Create the InfoPath Form Template

1. Create a new, blank, browser-compatible form template
2. Add a “Receive” type secondary data connection to the Add List Item Template.xml file created in Step #2. (Make sure the options “Include the data as a resource file in the form template” and “Automatically retrieve data when the form is opened” are enabled.)
3. Add a “Receive” type secondary data connection to the “MyContacts” SharePoint List created in Step #1 and make sure the option “Automatically retrieve data when the form is opened” is enabled.
NOTE: Be sure to include the “Title” field along with the custom fields we created.

Each SharePoint list is created with a unique identifier called a GUID. In order to submit items to a SharePoint list, you must know the unique GUID for that list. These next steps will enable you to identify the GUID for your “MyContacts” list.

Step 4: Identify the list GUID

1. Open a browser and navigate to the MyContacts list
2. From the Settings menu choose List Settings
3. In the browser’s address bar you will see the URL appended with “List=”

 

4. Copy everything after the equals sign and paste this into a text editor as we will need this value later on.

NOTE: We will need the list GUID to be formatted as “{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}”. If your GUID appears as above with the hyphens and braces “escaped” (i.e. %7B for the braces and %2D for the hyphens) then you will need to replace the escaped characters with the braces and hyphens so when we use this GUID later, it will appear as: {1E76517B-2C36-4473-A420-A737D98589BC}

Step 5: Add controls to the InfoPath Form Template

1. Open the Data Source Task Pane
2. From the Data Source dropdown box choose the “MyContacts” connection

3. Right-click on “MyContacts” and choose Repeating Table – this will add a repeating table bound to that connection to your View
4. From the Data Source dropdown box choose Main
5. Add a text box to the “myFields” node named: ListName and set the Default Value property to the GUID value of your list – we will use this node to specify the list when we perform the Submit operation

 

To update the SharePoint list we will be using the “UpdateListItems” method of the SharePoint “lists.asmx” web service. This web method requires a couple of parameters (the list name and what gets updated) – now that we have added the “ListName” node which contains the GUID and we have the Add List Item Template XML data connection which describes our data structure we have all the necessary information to add the “UpdateListItems” web method!

Step 6: Add the “lists.asmx” web service

1. Add a new “Submit” type of web service data connection to the “lists.asmx” web service – this is typically located at: http://servername/_vti_bin/lists.asmx
2. Select the “UpdateListItems” operation
3. Double-click the “listname” parameter and assign the “my:ListName” node as the value

4. Double-click the “updates” parameter, select the “Add list Item Parameter” data source, select “Batch” and click OK
5. For the “Include” option select “XML subtree, including selected element”

6. Complete the Data Connection Wizard

Now that we have all the connections that are required, we now need to add the “submit” functionality to the form template.

Step 7: Add Submit functionality

1. Display the Data Source Task Pane
2. From the Data Source dropdown box choose the Add List Item Template data connection
3. Drill down through the data source, right-click on the Field node and choose Repeating Table

 

We need to change the text box control in the “Name” column to Read-only – if these values were to be changed it would affect the CAML and the submit would fail.
• Double-click on the text box in the Name column of the Repeating Table
• Select the Display tab
• Enable the Read-only property and click OK
• Add a new Button control to the View
• Double-click the button to display the Properties
• Click the Submit Options button
• Enable the option “Allow users to submit this form”
• Enable the option “Perform custom action using Rules” and click the Rules button
• Click the Add button
• Click the Add Action button
• From the Action dropdown box choose “Submit using a data connection”, select the “Web Service Submit” data connection and click OK
• Click the Add Action button
• From the Action dropdown box choose “Query using a data connection”, select the “MyContacts” data connection and click OK (this will automatically refresh the list in InfoPath so you can see the newly added record)

• Click OK until you are back to your form

NOTE: If you want to automatically clear out the submitted values, add another action to this Rule to “Set a field’s value” and the only option you need to specify is the “Field” option – select the “Field” node from the “Add List Item Template” data connection and then simply leave the Value option blank.

Step 8: Test!

1. Click the Preview button to preview the form
2. Fill in values for each of the fields: Title, First Name, Last Name, E-mail and Phone

3. Click the Submit button – the contact information should be submitted successfully and the “MyContacts” list automatically updated!

A special thanks to Matt Faus of InfoPathDev for for initially posting this solution!

Scott Heim
Support Engineer

Posted: Monday, March 26, 2007 2:52 PM by infopath
Filed under:

Comments

Matt Faus said:

Thanks for this fancy reiteration of my post!  However, since people have been doing this for over a year now, I think a more helpful post would be on how to get this form to look good.  The schema does not allow for very easy representation with standard InfoPath controls.  We have discussed possibilities for solutions to this problem in our forums, but an elaborate (and codeless) example form would be stupendous!

# March 28, 2007 1:53 AM

Gerhard_Moschner said:

Any ideas how to integrate a dropdown list for any of the sharepoint list fields in the form?

# April 4, 2007 9:36 AM

Scott Heim said:

Hi Gerhard,

I am not sure I follow your question. For instance, what I can do is simply add another data connection to the same list and use this connection as the source of values for the dropdown list boxes - does that help?

Scott

# April 4, 2007 10:55 AM

Scott Heim said:

Hi Matt,

Thanks for your suggestion and again - thank you for the original post!

Any way I can ping you offline about your request?

Scott

# April 4, 2007 10:59 AM

techietex said:

Hi Scott,

Thanks for the article. I followed the steps described in this article. When I click submit I get the message saying "This form was submitted succesfully". But there is no new item in my contacts list. Do you know what I might be missing here?

# April 5, 2007 2:34 PM

Scott Heim said:

Hi - off the top of my head, the first thought is if you have the correct GUID specified for your list?

Scott

# April 5, 2007 2:38 PM

techietex said:

well, found the solution. I wrote a windows app to submit data to the same list I was trying earlier and that gave me the required error message.

I was getting:

The list or view of the list referenced here no longer exists.

found the solution to that in this KB article:

http://support.microsoft.com/kb/840549

# April 5, 2007 2:49 PM

Scott Heim said:

I am glad you found the cause of the problem!

Scott

# April 5, 2007 3:04 PM

Johnwe's SharePoint WebLog said:

This weekend I took some time to research and then test methods to post information from an Infopath

# April 14, 2007 6:22 PM

iota said:

Hi Scott,

My english is very poor! I think you will very difficually to understand the meaning for this quote :>

My problem is look like techietex.

I can submit the form and show the successful message. But the target list can not be update any information.

I double-checked the default GUID value in the ListName and sure this GUID as same as the traget list.

Do you have any idea ??  Waiting for your reply.

Iota

# April 18, 2007 9:16 AM

hesg said:

Hi!

I'm experiencing the same problem as iota and techietex. When I'm submitting my form I recieve a message that tells me that the data has been posted successfully. But of course, no item in the list.

I checked the GUID three times just to make sure. And I tried creating a new Team Site with a new List that the form could post to, but still the same result.

It's really strange...

# April 20, 2007 7:20 AM

doubter13 said:

Same thing here, double checked everything and tried it on two different sharepoint systems.

I do get the message that everything was submitted, but nothing appears in the list. Any suggestions?

# April 20, 2007 9:07 AM

doubter13 said:

OK, solved the Problem.

Somehow the GUID changes after the creation. I created the List, checked the GUId and tried it with that ID, with no success, then i added something to that list and rechecked the GUID and got another one, after trying again with that GUID it worked.

# April 23, 2007 8:39 AM

iota said:

Hi Doubter13,

I tried your solution in the last time but not successfully. Do me a favor, can you check some configure in your form and SP server as the following ?

1) Which type are you selected for your site ?

e.g. Document Library, Form Library, Custom List etc.

2) Do you define the ID field in the XML file ?

e.g. <Field Name = 'ID'></Field>

3) Would you please to check the DCOM services status in your IIS server ? I found the error messages for this in the Event Viewer - System. Please see the error detail as the following.

************************************

Event Type: Error

Event Source: DCOM

Event Category: None

Event ID: 10016

Date: 4/24/2007

Time: 4:31:10 AM

User: NT AUTHORITY\NETWORK SERVICE

Computer: ABCDE

Description:

The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID {73738744-F397-33D0-9953-00C04FD939C3} to the user NT AUTHORITY\NETWORK SERVICE SID (S-2-3-45).  This security permission can be modified using the Component Services administrative tool.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

************************************

Are you happen this problem in your server ?

Thank you for your Help.

IOTA

# April 23, 2007 11:04 PM

Scott Heim said:

Hi everyone,

Sorry for the delay in responding - I have been out of the office for the last week.

Doubter13 - glad to hear you have resolved the issue! For everyone else, a couple of points to check:

- If you have renamed the "Title" field to be your own name, the CAML query will still need to reference that field as "Title."

- Check the Application Event log and see if there are any errors or warnings when you test this process - we could be hitting a permissions issue based on the Application Pool Identity Account being used in the Application Pool for your site

Scott

# April 24, 2007 8:22 AM

cidras said:

- hi, Scott,  doubter13

I try checked GUID for my list. They are correct but  no items add to my list. Please, help me. Thanks

# May 8, 2007 3:18 AM

Scott Heim said:

Hi doubter13,

I thought you had this resolved? Have you renamed the "Title" field in your list? Are there any errors or warnings in the Application Event log or the server log?

Scott

# May 8, 2007 8:26 AM

Snaap said:

Hi guys,

Could you please help David (galetarconsulting.com) out, he posted a desperate message on my blog because I linked to this article, but he didn't know how to drop a comment here, or to get in contact with you all (I guess there's a need to register and login?). Anyway, here are his questions:

In section #3, it says:

"1. Create a new, blank, browser-compatible form template"

- What does it mean by this?

- How do I do this?

In the same section it says:

"2. Add a “Receive” type secondary data connection to the Add List Item Template.xml file created in Step #2.", and "3. Add a “Receive” type secondary data connection to the “MyContacts” SharePoint List created in Step #1"

- What does it mean by this?

- How do I do this?

Lastly, I need to place this form on the companies "Public" portion of the website (for anyone to fill out), while I collect the data in a "Private" part of the website, or the "Sharepoint" part of it.

PLEASE HELP- - - I WOULD REALLY APPRECIATE IT!!!!!!!!!

# May 8, 2007 4:32 PM

Scott Heim said:

Hi,

1. Create a new, blank browser-compatible form template

    - Launch InfoPath

    - Click Design a Form Template

    - Choose Blank and enable the option: "Enable browser-compatible features only"

2. You add data connections to an InfoPath Form Template by selecting Data Connections from the Tools menu and clicking Add. There you can choose whether the connection type is Submit or Receive

3. This is going to be challenging as I am assuming the "public" site is going to allow Anonymous Access. If so, then SharePoint security is designed to *not* allow any submissions to a library or list with Anonymous access enabled. As such, this process will change as the data will need to be submitted to a custom web service that you create to take the XML and create the list item for you.

Scott

# May 8, 2007 4:39 PM

cidras said:

I got items in my list (used file XML and GUID of my list). But I not add item in my list (used web service of sharepoint).

Please, help me.

# May 9, 2007 12:46 AM

Scott Heim said:

Hi Cidras,

If none of the other suggestions in these comments have been of benefit, then the best option would probably be a support case with Microsoft Product Support Services so this can be looked into further.

Scott

# May 9, 2007 1:34 PM

cidras said:

yeah, I added item in my list. Thank you, Scott.

# May 11, 2007 2:57 AM

ramkumar1910 said:

Am I missing someting?

Shouldnt we just add Lists.asmx as the datasource and pass the SPquery? Why do we have to do CAML?

# May 21, 2007 10:20 AM

fbrum said:

I everybody!

I'm a newbi on both Sharepoint and Info path.

I have a question.

In the xml template, is it possible to refer a field that in the sharepoint it's a Choice (menu to choose from), that is acombo-box.

If so, than how?

Thanks in advance for the attention.

# May 23, 2007 8:06 AM

sudhir.kesharwani said:

hi fbrum,

Hope this solves your problem :)

i have added a combo box name folderName and another text box named txtFolderName.

Whenever the selection changes for the combo box i am reading the value into the text box.

i have added manged code handler to the changed event of combo box ... (please note you will require VSTA installed onyour pc in order to add a .net code to your Infopath form)

public void folderName_Changed(object sender, XmlEventArgs e)

       {

           // Get reference to the root node.

           XPathNavigator root = this.MainDataSource.CreateNavigator();

           //Get the reference to the text box.

           XPathNavigator text = root.SelectSingleNode("/my:myFields/my:txtFolderName", this.NamespaceManager);

           //Get the selected value into text box.

           text.SetValue(root.SelectSingleNode("/my:myFields/my:folderName", this.NamespaceManager).Value);

}

combo box is prepopulated by reading a list items in my sharepoint server....

just go through the code,  its simple XML reading nothign else...

revert back to me if you need any info :)

hope this is what you were looking for...

Regards,

Sudhir

# May 28, 2007 8:57 AM

fbrum said:

Thanks!

That does clear things out. :)

# May 28, 2007 1:17 PM

apersson said:

Hi,

Is it possible to modify the procedure to submit the entire form to a forms library?

I know you can submit directly to a forms library, but we have a scenario with anonymous users and since we can not grant anonymous users write priviliges to libraries we need a method of submitting via a web service.

Cheers

apersson

# May 29, 2007 4:18 AM

Scott Heim said:

Hi apersson,

Here is a "sample" web service method for creating a new InfoPath XML file in a SharePoint library. To use this, you would:

- Create a new Submit data connection in InfoPath

- Point the "fileName" parameter to a node in your data structure (obviously you could hard code this as well)

- For the "fileContents" parameter you will choose "Entire form" and then enable the option: "Submit data as string"

[WebMethod]

   public void CreateInfoPathDocument(string fileName, string fileContents)

   {

       try

       {

           string pathFolder = "SubmitViaWebService"; //Where the form will be created

           SPSite site = new SPSite("http://server");

           SPWeb web = site.OpenWeb();

           SPFolder folder = web.Folders[pathFolder];

           if (fileName.IndexOf(".xml") == -1)

               fileName += ".xml";

           string fileUrl = folder + "/" + fileName;

           System.Text.Encoding e = System.Text.Encoding.UTF8;

           byte[] b = e.GetBytes(fileContents);

           SPFile file = folder.Files.Add(fileUrl, b, true);

       }

       catch (System.Exception ee)

       {

           throw new ApplicationException(ee.Message);

       }

   }

# May 29, 2007 10:01 AM

apersson said:

Thanks Scott,

Thank you for your fast reply.

So this can't be done without coding?

Cheers

apersson

# May 29, 2007 4:23 PM

Scott Heim said:

Hi,

Well - as you have seen, if anonymous access is enabled that anonymous user cannot submit directly to SharePoint. As such, you will need to create a custom web service to handle the submit and create the form - so no - there is no way (that I know of <G>) to do this without writing custom web service code.

Scott

# May 29, 2007 5:15 PM

apersson said:

Hi,

Yes, I understand that, I just figured that the lists.asmx web service could be used.

:) Actually, I think the major problem isn't that anonymous users can't submit to a library. I think the major issue is that for anonymous users to submit to a list you have to give them view priviliges as well.

Cheers

apersson

# May 30, 2007 3:00 AM

iceeicee24 said:

Hi Scott,

I tried to follow all the steps you mentioned and encountered no error but when i started to submit the form, i am recieving 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/">The system cannot find the file specified. (Exception from HRESULT: 0x80070002)</errorstring></detail>

How am i gonna solve this? Please advise.

Thanks,

icee

# May 30, 2007 7:28 AM

Scott Heim said:

Hi icee,

Did you try the *exact* steps I documented? I have not seen this specific error before regarding this process so the first thing to make sure of is that you are following the exact steps - no changes. Then once this sample is working, move forward with your actual scenario.

Scott

# May 30, 2007 10:10 AM

IHunter said:

This tutorial worked for me.  The one thing I ran into and corrected is when setting up the webservice on a teamsite the servername in the following example must contain the full path to the team site you want to create this webservice for.

http://servername/_vti_bin/lists.asmx

# May 30, 2007 3:37 PM

IHunter said:

I do have a question though.  In this tutorial you're only using a CAML template, which is only allowing me to use a repeating table.  The repeating table is the exact format as the list form on sharepoint which I'm trying to break away from.  

Is there any way to design a form the way you want and have the fields send to a sharepoint list.  and if not is there any way to have a form update the fields in the CAML list so I don't have to comprimise the look of my form?

# May 30, 2007 3:42 PM

iceeicee24 said:

Thanks scott and hunter,i think i made a mistake in the url of the web service, now it submits successfully, thanks

# May 30, 2007 9:15 PM

darryl2912 said:

Hi Scott,

When I hit the Submit button I get the following error. I have followed the exact steps as what is in the blog. Can you please urgently help me with this matter.

The error is:

The data connection MyContacts is using a URL: http://auperadev03:82/sites/ChangeControlPortal/ChangeControlDev03Site/Lists/MyContacts/AllItems.aspx

The error I am getting is as follows:

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/ChangeControlPortal/ChangeControlDev03Site".</errorstring></detail>

Kind Regards

darryl2912

# May 30, 2007 11:18 PM

darryl2912 said:

Hi Scott,

I figured this one out.

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

darryl2912

# May 31, 2007 1:53 AM

darryl2912 said:

Hi Scott

In submitting the InfoPath form according to your blog, which I now have got it to work I want to be able to also submit with that form an attachment. Do you know how to do this using the CAML approach that you had used in your blog. It must be possible but I do not know how to. Any other blogs or have you got a solution for this as well. What can I place in the xml to get it to work. This would be very handy for us.

Kind Regards

darryl2912

# May 31, 2007 2:06 AM

zullu said:

Hi Scott Heim,

I have a problem when submitting a infopath form to a doc library. I am a newbie, tried to follow the steps defined in thw url:

http://articles.icscentral.com/Kb%20Articles/274/826993.aspx

But when I test my form, I get an error:

"InfoPath cannot submit the form.

The OnSubmitRequest event handler returned a value indicating that the submit failed"

When I tried debugging the code, I found error is generated on line: [oXmlHttp.Open("HEAD", strUrl, false;]

and by placing the code below in the Catch(ex) section

XDocument.UI.Alert(ex.message);

XDocument.UI.Alert(ex.number);

I get the message as "Permission denied". The error number returned is "-2146828218".

Any clue as to why is this happening.

I have even given full control acess to the site and have created a "Test" Doc Lib so my strUrl is "http://oss1/sites/PnP/Test/testform.xml"

Thanks for any help.

zullu

# June 6, 2007 11:54 AM

infopath said:

Hi darryl2912,

I am been testing functionality to include an attachment but have not been 100% successful. When I have some time to work on this, I will look at it again and if successful, will modify this post.

Zullu,

Based on the error, it seems you still have a Permissions problem. Try creating a submit connection in the InfoPath UI to the same library...can you submit without any error?

Scott

# June 6, 2007 1:12 PM

chirag65303 said:

I can view the List Item Data in Infopath form as well I can Add the New List Itsm in Sharepoint List through this code. Its working fine.

I am looking for the updating existing list Itmes data through this UpdateListItem web service but not able to get through...

plz look in to it..thanks

# June 6, 2007 4:10 PM

gorpade said:

Thanks for the article. I followed the steps described in this article. When I click submit I get the message saying "This form was submitted succesfully". But there is no new item in my contacts list. Do you know what I might be missing here?

Thanks for any help?

# June 7, 2007 7:27 AM

infopath said:

Hi gorpade,

Have you reviewed the comments in this post to see if any of them help? A number of folks have received this same behavior and were able to resolve the problem. Make sure the list service you are calling is for the appropriate site.

Scott

# June 8, 2007 11:23 AM

infopath said:

Hi zullu,

Have you looked at the Application Event Log or the Server logs to see if there are more details to the error? Is this a browser form? If so, you will probably need to change the logging options to Verbose for the Forms Services logging operations.

Scott

# June 12, 2007 4:45 PM

ndiem said:

How would you handle a repeating table/section with the SharePoint list?  

# June 13, 2007 4:47 PM

infopath said:

Hi ndiem,

I have not tried this but just off the top of my head, you could use code to enumerate the nodes in your repeating table and execute the web service/CAML directly.

I don't know that there is a way to do this without a custom code procedure.

Scott

# June 14, 2007 9:46 AM

kaj said:

How would you write code to enumerate the nodes in a repeating table and then execute a web service?

Can you point me to any samples or tutorials?

Thanks.

# June 14, 2007 11:02 AM

infopath said:

Hi kaj,

Here is some sample code I wrote to simply enumerate the existing contacts returned from the list and subsequently update those same contacts with the new values entered in the table. You could use this as a basis for how to accomplish what you need:

public void CTRL26_5_Clicked(object sender, ClickedEventArgs e)

       {

           //Create a new instance of our "Lists" web service

           server.Lists myList = new SubmitToSharePointList.server.Lists();

           //Pass the logged on users credentials to the web service

           myList.Credentials = System.Net.CredentialCache.DefaultCredentials;

           //myList.Credentials = new System.Net.NetworkCredential("user", "password", "domain");

           //Create a DataSource object for our list data source

           DataSource dsContacts = this.DataSources["MyContacts"];

           //Create a Navigator object so we can enumerate the list

           XPathNavigator xnContacts = dsContacts.CreateNavigator();

           //Create a NamespaceManager object so we can use the various namespaces on our XPATH expressions

           XmlNamespaceManager ns = this.NamespaceManager;

           //Create a NodeIterator object to enumerate all of the existing contacts

           XPathNodeIterator xi = xnContacts.Select("/dfs:myFields/dfs:dataFields/dfs:MyContacts", ns);

           //Enumerate each existing contact and update the values in each record with the changed information

           while (xi.MoveNext())

           {

               //Create XPathNavigator objects for each field from our list

               XPathNavigator xnID = xi.Current.SelectSingleNode("@ID", ns);

               XPathNavigator xnFirstName = xi.Current.SelectSingleNode("@FirstName", ns);

               XPathNavigator xnLastName = xi.Current.SelectSingleNode("@LastName", ns);

               XPathNavigator xnTitle = xi.Current.SelectSingleNode("@Title", ns);

               XPathNavigator xnEmail = xi.Current.SelectSingleNode("@Email", ns);

               XPathNavigator xnPhone = xi.Current.SelectSingleNode("@Phone", ns);

               //Create a new XmlDocument to use for specifying the Update CAML query

               XmlDocument doc = new XmlDocument();

               //Create the needed update element

               System.Xml.XmlElement updates = doc.CreateElement("Batch");

               string strOperation = "Update";

               //Create the CAML query passing in the value of each of our fields from the form

               updates.InnerXml = string.Format(@"<Method ID='1' Cmd='" + strOperation + "'>" +

               "<Field Name='ID'>" + xnID.Value + "</Field>" +

               "<Field Name='FirstName'>" + xnFirstName.Value + "</Field>" +

               "<Field Name='LastName'>" + xnLastName.Value + "</Field>" +

               "<Field Name='Title'>" + xnTitle.Value + "</Field>" +

               "<Field Name='Phone'>" + xnPhone.Value + "</Field>" +

               "<Field Name='Email'>" + xnEmail.Value + "</Field>" + "</Method>");

               //Update the list

               XmlNode node = myList.UpdateListItems("EAD1852F-6884-47B0-B928-BCB167698784", updates);

               dsContacts.QueryConnection.Execute();

           }

       }

# June 18, 2007 11:27 AM

presack said:

Excellent work Scott (and Matt).

I am a beginner.  I got the demo working but have a couple of questions.

I would like to essentially implement the solution you have done, except with two changes:

1)  I would like the ability to customize the look of the form some more, which has been mentioned elsewhere in the thread, including by Matt.  So I assume there is nothing new in that regard and will continue monitoring this and other forums.

2)  I would like to be able to do this with a document library.  Everything I find seems to be on how to submit the actual form to the library.  What I am attempting is a little bit different from the examples I have found- I want the user to be able to browse to a file to upload to the document library (just like in Sharepoint), to collect all of the other fields I need just as in your list example, and then click submit to create a new entry in the document library with the "browsed-to" file as the file in the document library.

FYI- The reason for doing this instead of just the Sharepoint add, in our case, is so I can gain some more control (and provide choices from some different data sources) for their selections for the other columns that will ultimately describe the document.

I hope that makes sense.  Thanks in advance.

presack

# June 20, 2007 11:36 AM

infopath said:

Hi presack,

Agreed - it would be nice to have a re-design of the form but I just have not had time to think about this much - sorry.

Regarding your 2nd question - is your form designed for the browser for for the client?

Scott

# June 21, 2007 11:13 AM

presack said:

Thanks for the response, Scott.

No problem on point one- that's what I figured.  I am not far enough along right now in my experience (thus the novice post) to develop a way myself yet.

I am currently planning on using the browser-enabled form, but using the client is an option in our environment.  All users have InfoPath 2003 SP1.

Thanks,

presack

# June 21, 2007 12:18 PM

infopath said:

Hi presack,

If your preference is a browser form, you may want to look at using a custom ASPX page with the XmlFormView control. This way you can easily provide an option to allow your users to "browse" for a file to upload.

Then you could create a web service on your SharePoint server that uses the SharePoint Object Model functionality to grab the selected file and upload it to the appropriate document library. I don't have any sample code on this but you should be able to search around and find something - maybe on a SharePoint BLOG.

Here is a link to using the XmlFormView control:

http://msdn2.microsoft.com/en-us/library/aa701078.aspx

Scott

# June 21, 2007 5:50 PM

presack said:

Thanks again.  That looks like a potentially workable solution.  Another article I found that may be of interest to people in this thread (although it is not an Infopath solution- sorry!) is below:

http://msdn2.microsoft.com/en-us/library/ms916819.aspx

It provides the ability to customize Sharepoint List forms (both the input and the display).  It looks to me like it has some drawbacks, but I'm not in a position right now to have the time to implement it.  I just thought it was worthy of note.

presack

# June 22, 2007 9:30 AM

Giannis said:

Hi,

I try to complete the “Submitting to a SharePoint List” but I have the same problem that read in your comments “When I’m submitting my form I recieve a message that tells me that the data has been posted successfully. But of course, no item in the list.”. I checked everything again and again but the problem remains. I try the example with Contact List of MOSS (Parent example from Matt Faus) and works (needs a simple change on GUID and Submit button). I try to create my own list (in same site and area with contact list) and run the example but the result was dishearting. I check the settings of two lists (mine and contacts)no difference except field “Title” that included only in my list. Did anybody knows the reason?

Giannis

# July 4, 2007 8:49 AM

Giannis said:

Hi Scott,

in an template example that you given at June 18 to kaj you use

"server.Lists myList = new SubmitToSharePointList.server.Lists();"

I try it but I cann't find the assembly reference. An idea please.

thanks for your help.

Giannis

# July 5, 2007 3:55 AM

mavsguy842 said:

Hey all,

I've followed all of the steps in this example and am getting everything to work perfectly except:

I need to have this form be browser-enabled so that clients without InfoPath can fill out the form and thus populate a SharePoint list without ever being directed to the List's actual add item page.

When starting the template I enabled browser enabled features only, so I figured this wouldn't be a problem, but it seems to be.  The design checker tells me "Invalid form Template" and the detail box says "An unexpected error has occured while verifying the form template."

I'm wondering if this might be a problem with how Forms Services is configured on the server, or any other suggestions you might have.  

Thanks,

Matt Callaway

# July 5, 2007 3:58 PM

ishayb said:

Hello,

How can I create initially automatic file name when the user clicks on "submit" button (at web InfoPath on the ribbon area)?

Tools-> submit options-> to SPS '07

Sample: "file_" + now() + userName

Thank for original post.

Ishay

# July 8, 2007 8:42 AM

UKaren said:

Hello,

may be you can give me a hint how to do this:

I can insert new items to the list as long as I don't use a field that contains a Person/Group-Field. I think, I need a GUID or something like this for the person-Field - but where can I get the information from?

I tested with a GIUD-like value I got from the webservice:

userprofileservice.asmx - GetUserProfileByName. But this doesn't work.

Any idea what's correct?

# July 9, 2007 8:16 AM

infopath said:

Hello everyone,

My apologies for the delay in responding.

For Giannis:

- Make sure you are using the appropriate web for the "Lists.asmx" web service. For instance, if your List is at: http://server/Lists then you would use something like http://server/_vti_bin/lists.asmx. However, if your List is at: http://server/site/Lists then you would want to use something like this: http://server/site/_vti_bin/lists.asmx

- Regarding the "Assembly reference" you are asking about - make sure you are developing on your SharePoint server box

For Matt Callaway:

- Have you been able to resolve this issue? When I developed this sample, it was with browser-compatibility enabled so this should work without issue. Let me know if you are still experiencing a problem.

For Ishay:

- You will want to use the "concat" function to concatentate text, functions and/or field names.

For UKaren:

- The only way I have been able to accomplish this (adding a new item with a Person/Group field) is to use code to insert the new item. I tested this with the "Tasks" list and was able to use the Contact Selector control on the form to allow the user to select a person. I then use a custom .NET web service to open the appropriate "web", create an "SPUser" object and return the "ID" of that user. This is what I finally use to set the "AssignedTo" field.

Thanks everyone for your patience!

Scott

# July 11, 2007 8:15 AM

ishayb said:

Hello Scott,

My scenario is:

After I Open a web infopath form and complete all input fields then I submit the new form.

now the form is save automatic in sps list

_________________

How can I Generate a unique identifier  prameter when i create new item on infopath automatically ?

(mynane + unique_id() -> save automatically into sps list)

T U

IshayB

# July 11, 2007 10:49 AM

infopath said:

Hi Ishay,

There are a number of ways to create a unique ID:

- Use a data connection to a database that increments a number and returns that to you

- Use a web service that does something similar, etc.

There is not a built-in way to get the unique identifier from SharePoint since this does not get assigned until after the form has been submitted.

Probably the easiest method is to either use a web service that gets the next value from a database or, if you are already using code in your form, you could generate a GUID value and add this to your form name.

Scott

# July 11, 2007 2:21 PM

UKaren said:

Hi Scott,

thanks for your answer. It works fine.

It helped me to find the following:

Use Webservice UserGroup.asmx - GetUserInfo

The result contains an ID and Name-Node.

Concat them to a string like ID;#Name. This is what you have to paste to the field you want to update. This works as well for groups. Use GetGroupInfo instead.

Another problem:

The name of the column "Assigned To" in the tasklist has a blank in its name. I haven't found a way to update columns with a blank in its name (whatever datatype they have). Any idea how to overcome this?

There are lots of columns coming from Microsoft with blanks and I don't want to customize them every time...

# July 12, 2007 5:16 AM

infopath said:

Hi UKaren,

I am not sure I follow what you mean by a "blank" in its name. How are you determining this? When I go to my Tasks list and click New, I see the AssignedTo field but when I click in that field I don't have a blank.

Sorry if I am missing something obvious.

Scott

# July 12, 2007 9:24 AM

UKaren said:

Hallo Scott,

sorry - for my bad english. on all sharepoint-server I have access to the column name of the AssignedTo field is written as "Assigned To" - between Assigned and To there is a character (Ascii 32). That's what I call "a blank".

# July 13, 2007 8:41 AM

infopath said:

Hi UKaren,

Thank you for the clarification - now I understand!

In actuality, when you are setting the "Assigned To" column to a value, the underlying column name is "AssignedTo". This appears to be true of most, if not all, of the column names. Even though they show spaces, the actual names do not contain a space.

For instance, "Start Date" is actually "StartDate", "Workflow Name" is "WorkflowName".

If you ping a SharePoint Blog you may find a better way to determine this - I use this tool:

http://www.sharepointblogs.com/mossman/archive/2007/04/11/u2u-caml-query-builder.aspx

Please note this is not a recommendation - merely a tool I use to help build the CAML queries since I am not a SharePoint expert! :)

Scott

# July 13, 2007 8:54 AM

realminds said:

UKaren, u can use SharePoint Explorer (latest version which support MOSS 2007) to see the actual values of field names.

# July 17, 2007 8:04 AM

Giannis said:

Thank you Scott,

Sorry am late to answer you. I have already find the way to do what I asked.

I apologies that I thought  what you write in your example  I must type it as is. I understand later the changes.

Thanks again.

# July 18, 2007 9:06 AM

infopath said:

Hi Giannis,

That is great to hear! I am glad it is working for you now.

Scott

# July 18, 2007 10:10 AM

realminds said:

Hi,

Following can be used to get the Unique UserID to be passed in "Assigned to" in the task list.

Private Function sGetUserID(ByVal sUserID As String) As String

           Dim strUserID As String = ""

           Dim ugp As New WSUG.UserGroup()

           ugp.Credentials = New NetworkCredential("User", "Pwd", "Domain")

           Dim NDUser As XmlNode = ugp.GetUserInfo(sUserID)

           Dim xnrUserInfo As XmlNodeReader = New XmlNodeReader(NDUser)

           While xnrUserInfo.Read()

               If xnrUserInfo.Name = "User" Then

                   strUserID = xnrUserInfo.GetAttribute("ID")

               End If

           End While

           Return strUserID

       End Function

# July 20, 2007 4:29 PM

mavsguy842 said:

Scott,

Thanks for getting back to me.  Through much more extensive testing of many different scenarios/forms I've come to believe something is wrong with the installation of my Forms Server.  Even when I create a simple form with only one text box I receive multiple errors:

1) When publishing, InfoPath says that the form will not be able to be opened from within a browser - "Invalid Form Template."

2) "Unknown Error" on the SharePoint site when attempting to Create New from within the form library.

3) "Unknown Error" on the SharePoint Server when attempting to upload a form directly to the server (not by publishing).

If you have any suggestions I'll take them, but I'm pretty sure this is NOT a problem with your example.

Thanks,

Matt Callaway

# July 24, 2007 11:01 AM

smacky311 said:

I tried publishing this completed form as a browser enabled content type.  The form will launch, but it will not submit.  I get an error when I hit submit and the list does not update.  I have even added some custom code I found online and have been unsuccessful in making this form work in a browser.  Has anyone been able to do it?  

Regards,

Brian

-To be clear, the form works perfectly fine when launched from inside the Infopath client, but not from the browser enabled infopath form setup as a content type in a document library.

# September 5, 2007 8:21 PM

infopath said:

Hi Brian,

I just tested this process after pubishing my XSN as a Site Content Type and it worked from the browser without issue.

If you would, try these steps:

- Delete the Content Type from the document library where you added the published content type

- Delete it from the Site Content Type list

- Delete the XSN from the saved location

- Create a new library on the same site called: ContentTypes

- Publish the XSN as a Site Content Type and save it in the ContentTypes library

- Add it as a Content Type to your document library

- Test

Scott

# September 11, 2007 4:01 PM

Deniz Yalman said:

Hi Scott,

I am trying to allow anonymous users to submit items to Sharepoint List using "Infopath Form Services" over the browser, but I am facing some issues.

In order to achieve this, I have created a web service as you have explained in here:

http://blogs.msdn.com/infopath/archive/2007/03/26/submitting-to-a-sharepoint-list.aspx#2969087

I can submit the form through infopath as "string as data", but when I try to submit it using form services over the browser, it fails returning an error: "Infopath cannot submit the form".

Are anonymous users not allowed to add items to sharepoint list using infopath form services?

Also, can this issue (allowing anonymous users to add items to sharepoint list through form services) be overcome with another method?

Thanks in advance

# September 20, 2007 7:36 AM

infopath said:

Hi Deniz,

Chances are this is a login/permissions issue. When you use the InfoPath client you are coming in as that logged on user; however, when using the browser you will be trying to create the form as the identity specified in the Application Pool for your site.

Have you taken a look at your server logs? Reproduce the error, then open the latest server log, scroll to the bottom and then do a search "up" for Forms Services - you will probably find an error regarding authorization, permissions, etc.

Scott

# September 20, 2007 5:18 PM

yannis said:

Regarding the "Invalid property name", "Duplicate property name namespace in file schema.xsd" error messages, I have got over them by removing a "<xs:anyAttribute namespace="http://www.w3.org/XML/1998/namespace" processContents="lax"/>" reference that I found in the schema.xsd file.

After you remove this reference, do not forget to "Convert Main Data Source" with the new schema file and check that your data source is intact.

# October 3, 2007 10:19 AM

ghodnett said:

Hi there,

This post has helped me a lot, but I can't figure out how to retrieve and update a specific list item. I need to be able to click a link in a sharepoint item list, that will open the Infopath form used to edit that item and do the necessary processing, and then save the changes to that specific item.

It sounds like it should be easy enough!

Thanks,

Garth

# October 8, 2007 5:25 AM

infopath said:

Hi Garth,

Unfortunately it is not as easy as it may seem. The only way I have found to do this is to custom code because you need to be able to modify the CAML query to tell it what type of edit you are doing (i.e. New, Delete, etc.) and then for which item in the list.

Using the steps in this sample, I have modified the table structure returned from the list to add a new column. This column simply holds a button that would be used to "update" the data in that row. Here is some sample code that I have used to accomplish this:

- On the click event of this button, I have just this code:

UpdateList("Update", e.Source.CreateNavigator());

- Here is the "UpdateList" procedure:

public void UpdateList(string strOperation, XPathNavigator e)

       {

           //Create a new instance of our "Lists" web service

           serverName.Lists myList = new serverName.Lists();

           //Pass the logged on users credentials to the web service

           myList.Credentials = System.Net.CredentialCache.DefaultCredentials;

           //Create a DataSource object for our list data source

           DataSource dsContacts = this.DataSources["MyContacts"];

           //Create a NamespaceManager object so we can use the various namespaces on our XPATH expressions

           XmlNamespaceManager ns = this.NamespaceManager;

           //Create XPathNavigator objects for each field from our list

           XPathNavigator xnID = e.SelectSingleNode("@ID", ns);

           XPathNavigator xnFirstName = e.SelectSingleNode("@FirstName", ns);

           XPathNavigator xnLastName = e.SelectSingleNode("@LastName", ns);

           XPathNavigator xnTitle = e.SelectSingleNode("@Title", ns);

           XPathNavigator xnEmail = e.SelectSingleNode("@Email", ns);

           XPathNavigator xnPhone = e.SelectSingleNode("@Phone", ns);

           //Create a new XmlDocument to use for specifying the Update CAML query

           XmlDocument doc = new XmlDocument();

           //Create the needed update element

           System.Xml.XmlElement updates = doc.CreateElement("Batch");

           //Create the CAML query passing in the value of each of our fields from the form

           if (strOperation == "Delete")

           {

               updates.InnerXml = string.Format(@"<Method ID='1' Cmd='Delete'>" +

               "<Field Name='ID'>" + xnID.Value + "</Field>" + "</Method>");

           }

           else

           {

               //Create the CAML query passing in the value of each of our fields from the form

               updates.InnerXml = string.Format(@"<Method ID='1' Cmd='Update'>" +

               "<Field Name='ID'>" + xnID.Value + "</Field>" +

               "<Field Name='FirstName'>" + xnFirstName.Value + "</Field>" +

               "<Field Name='LastName'>" + xnLastName.Value + "</Field>" +

               "<Field Name='Title'>" + xnTitle.Value + "</Field>" +

               "<Field Name='Phone'>" + xnPhone.Value + "</Field>" +

               "<Field Name='Email'>" + xnEmail.Value + "</Field>" + "</Method>");

           }

           //Update the list

           XPathNavigator xnListGUID = this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:ListName", ns);

           XmlNode node = myList.UpdateListItems(xnListGUID.Value, updates);

           //Requery the data source to reflect the updates

           dsContacts.QueryConnection.Execute();

       }

As you can see, this code can also handle a "Delete" submission as well.

Scott

# October 8, 2007 9:42 AM

ghodnett said:

Hi Scott,

Thanks for the reply! How do I open an Infopath form, from a Sharepoint list item (e.g. by clicking on an icon)? I assume I can put the form into a Sharepoint webpart? And, is it possible to pass a parameter to that form, that I can use in one of it's fields?

Thanks,

Garth

# October 9, 2007 8:00 AM

infopath said:

Hi Garth,

Not sure I follow the first question...are you asking how to click on a SharePoint list item and that will open an InfoPath form? If so, I am not sure how you would accomplish this - a Content Query Part may be the answer.

In regard to the parameters question, take a look at this blog post:

http://blogs.msdn.com/infopath/archive/2007/02/26/passing-data-into-a-form-input-parameters.aspx

Scott

# October 9, 2007 11:13 AM

ghodnett said:

Hi Scott,

Perhaps I'm approaching my problem in the wrong way. Basically, I've got an employee list that shows where employees are, when they left and when they will be back. An employee needs to be able to click on an icon in their line that will open a form that allows them to select a location and a time of return and this must also start a workflow. Currently I am doing this using content types - the employee clicks on the edit icon that opens a content type that allows them to either select a location with a specific time, or to enter a location and return time. This was easy to and works, but it does not give me the flexibility to do all the processing that I need to (the processing that I need to do is very basic, but I find have to use multiple calculated fields rather than a few lines of code). That's why I was thinking of opening an infopath form from the line. But maybe you could suggest another way?

The problem is that,although I am a developer, I don't know much about web development, Sharepoint or .net. Is there a way to put code on the sharepoint fields, like I could put code on SQL field? I feel a bit frustrated because I know the logic I need to apply, but I don't know where to put it!

Thanks,

Garth

# October 15, 2007 6:42 AM

infopath said:

Hi Garth,

Unfortunately, I am not a workflow expert. In fact, with the group I am with (InfoPath support) we see very little of the workflow issues as they are primarily handled by our SharePoint folks (at least from an Office workflow perspective.)

I don't mean to dance around your question but I don't want to steer you in the wrong direction. Have you seen the SharePoint/Workflow blog: http://blogs.msdn.com/sharepoint/archive/tags/Workflow/default.aspx ?

You may want to post here and see if you can get some better direction.

Now, what I am wondering is this: you mentioned that you are currently doing this with "Content Types." You can certainly publish an InfoPath Form Template (XSN) as a Site Content Type as well. Without knowing exactly how you are launching the content types, I wonder if this would provide any benefit? With this being an InfoPath Form Template simply published as a Content Type you can certainly manipulate the data the same way as if you published the form as any other type.

Scott

# October 15, 2007 10:19 AM

mpang said:

I am new to InfoPath.  I tried this and it worked perfectly.  Can you elaborate on your response dated in April about integrating a dropdown column in a sharepoint list with infopath? It would be great if you could list the key steps.  Thanks!

# October 18, 2007 2:39 PM

infopath said:

Hi mpang,

What I was referring to in my response was adding a secondary data connection in your InfoPath Form Template (the XSN file) that was a connection to a SharePoint list. You can then use that connection as the source of data for your dropdown box in your InfoPath file.

However, if what you are asking is how to consume a "Choice" type of column from SharePoint in your InfoPath Form Template there is no direct way for this in InfoPath.

Scott

# October 19, 2007 8:34 AM

infopath said:

Hi jrk555,

Here is sample code that I just tested that works for me - obviously I am just hard-coding some values but try this and see if it works for you. This is the code I have in the click event of a button:

//Create a new instance of our "Lists" web service

server_Lists.Lists myList = new SubmitToSharePointList.server_Lists.Lists();

//Pass the logged on users credentials to the web service

myList.Credentials = System.Net.CredentialCache.DefaultCredentials;

//Create a DataSource object for our list data source

DataSource dsContacts = this.DataSources["MyContacts"];

//Create a NamespaceManager object so we can use the various namespaces on our XPATH expressions

XmlNamespaceManager ns = this.NamespaceManager;

//Create a new XmlDocument to use for specifying the Update CAML query

XmlDocument doc = new XmlDocument();

//Create the needed update element

System.Xml.XmlElement updates = doc.CreateElement("Batch");

//Create the CAML query passing in values

updates.InnerXml = string.Format(@"<Method ID='1' Cmd='New'>" +

"<Field Name='FirstName'>ABC</Field>" +

"<Field Name='LastName'>DEF</Field>" +

"<Field Name='Title'>EE</Field>" +

"<Field Name='Phone'>980-555-1212</Field>" +

"<Field Name='Email'>abc@hotmail.com</Field>" + "</Method>");

//Update the list

XPathNavigator xnListGUID = this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:ListName", ns);

XmlNode node = myList.UpdateListItems(xnListGUID.Value, updates);

//Requery the data source to reflect the updates

dsContacts.QueryConnection.Execute();

I would try this with a new form and even go so far as to hard code the field values and the list GUID - this way you can take all variables out of the picture and see if you can get this to work.

Scott

# October 19, 2007 8:57 AM

jrk555 said:

Hi Scott,

Thanks for taking time to check on it.

I resolved the issue i am having. When we add a web reference to the lists web service, we need to include ?wsdl at the end. So it has to be something like http://server/site/_vti_bin/lists.asmx?WSDL.

I didnot include that initially. I included that now and its working fine.

Appreciate your help and thanks for posting this article.

-jrk555

# October 19, 2007 1:05 PM

infopath said:

Hi jrk555,

Excellent! Glad you have this working...

Scott

# October 19, 2007 1:09 PM

indiarocks said:

Hi Folks,

I have followed the exact steps as mentioned above but i am getting the message "The form was submitted sucessfully" but actually the item is not added into the list. I have ensured the correct GUID. I can see that many people have faced the same problem so hoping to get the exact solution of this problem...

Hope to get the response soon.

Thanks and Regards,

S

# October 22, 2007 11:42 AM

indiarocks said:

Hi Guys,

Could anybody reply me about my problem? I will appreciate if someone could. I am stuck with that as i am not able to inserting item into list even after following the above steps...

Thanks a lot in advance...

My mail id is software.sanjay@gmail.com

Thanks,

Sanjay.

# October 22, 2007 1:35 PM

infopath said:

Hi Sanjay,

Make sure you are referencing the correct "Lists.asmx" web service. For instance, if your list is at http://server/lists/list_name then the web service you will want to use is http://server/_vti_bin/lists.asmx; however, if your list is at http://server/site/lists/list_Name then the web service you need to use is http://server/site/_vti_bin/lists.asmx.

Scott

# October 22, 2007 3:49 PM

infopath said:

Hi Sanjay,

Please excuse my lack of SharePoint knowledge here...but have you tried:

http://servername/SiteDirectory/SanjaySite/_vti_bin/lists.asmx

Scott

# October 23, 2007 8:04 AM

indiarocks said:

Hi Scott,

There is no lists.asmx file at the URL http://servername/SiteDirectory/SanjaySite/_vti_bin/lists.asmx

Thanks and Regards,

Sanjay Patel.

# October 23, 2007 10:39 AM

infopath said:

What is "SiteDirectory" in your URL? Is that a site or something else? For instance is http://servername/SanjaySite the same as http://servername/SiteDirectory/SanjaySite?

Scott

# October 23, 2007 10:42 AM

shakes11 said:

Hi Scott,

Since it is not possible to rename the "Title" field in the CAML file, is there a way to hide it? I would like to create an InfoPath form that links to an existing list and I would like for users not to see the "Title" field when they fill it out.

Greatly appreciated!

# October 29, 2007 2:58 PM

infopath said:

Hi shakes11,

Sure - try the following using the sample from this post:

- Right-click on the Repeating Table used to add new items and select Conditional Formatting

- Click Add

- From the first box choose the field: Name

- From the second box choose: is equal to

- From the last box choose Type Test and enter: Title

- Select Hide this control

- Test!

What this will do is prevent the Title field from showing in this repeating table. Now, you can submit items without a title but, by default, the title field shows in the list and a new item without a title shows: "No Title."

Scott

# October 31, 2007 5:13 PM

shakes11 said:

Thanks Scott, it works!! My next question (and i think i might have the answer to this already, but I just wanted a confirmation) is if I want to point to a list that already exists, and the Title field has been renamed, is it possible to still link to it?

I am assuming the answer is no, because I tried, with no success (I am guessing that one of the columns is the title field, I did not try all of them).

Thanks again!

# November 1, 2007 9:51 AM

infopath said:

Hi shakes11,

Chances are it was just the "caption" that was changed - the underlying name of the field is probably still "Title."

Scott

# November 1, 2007 10:01 AM

infopath said:

Hi Leary,

I too spent some time trying to get this to work in a similar fashion as the "add" but kept running into issues...and then ran out of time to continue working on it.

The way I do this now is to use custom code - there is a sample earlier in this post.

Scott

# November 28, 2007 11:47 AM

paras2020 said:

Hi Team,

I have followed every step in this article. I receive this error:

" An error occured while the form was being submitted."

Thank you.

# December 3, 2007 9:49 AM

paras2020 said:

OK, Please ignore the above post. I am getting a new error.

Records were submitted. But I am not seeing it in the list.

Thank you.

# December 3, 2007 11:03 AM

paras2020 said:

OK, Please ignore the above post. I am getting a new error.

Records were submitted. But I am not seeing it in the list.

I checked the GUID. Nothing was modified.

Thank you.

# December 3, 2007 11:03 AM

paras2020 said:

I made even more progress...

When I add a new task in the list via Sharepoint it loads in the Infopath form.

When I try to add records to Sharepoint via Infopath. It does not work. Do you have any idea as to why this is not working.

Thanks.

# December 3, 2007 12:06 PM

infopath said:

Hi paras2020,

A couple of things to check:

- Make sure you are using the correct "lists.asmx" web service for your site

- Make sure the fields you reference in the "Add List Item Template.xml" file contain valid fields that actually exist in the list.

Scott

# December 3, 2007 1:07 PM

paras2020 said:

BTW....is there a math function in Infopath which an create a random as the form loads. Sorry for going off topic.

Thanks in advance.

Paras

# December 3, 2007 1:43 PM

paras2020 said:

Here is my XML and content of the custom list. I do not see anything wrong with it. Do I need to include an ID field? Thank you for taking the time to help me out.

Column (click to edit) Type Required  

Title   Single line of text  

useremail   Single line of text  

category   Single line of text  

usercontactname   Single line of text  

Userdepartmentservice   Single line of text  

Userbranchbusiness   Single line of text  

Usercategory   Single line of text  

Userdescription   Single line of text  

Userpcrnumber   Single line of text  

Userdaterequired   Single line of text  

Userifmandatory   Single line of text  

Userequipment   Single line of text  

Userlocationofservice   Single line of text  

Userrequestno   Single line of text  

Userrequestdate   Single line of text  

Status  Choice  

Created By  Person or Group  

Modified By  Person or Group  

<?xml version="1.0" encoding="UTF-8"?>

<Batch OnError="Continue">

   <Method ID="1" Cmd="New">

<Field Name='Title'></Field>

       <Field Name="useremail"></Field>

       <Field Name="category"></Field>

       <Field Name="usercontactname"></Field>

       <Field Name="Userdepartmentservice"></Field>

<Field Name="Userbranchbusiness"></Field>

<Field Name="Usercategory"></Field>

<Field Name="Userdescription"></Field>

<Field Name="Userpcrnumber"></Field>

<Field Name="Userdaterequired"></Field>

<Field Name="Userifmandatory"></Field>

<Field Name="Userequipment"></Field>

<Field Name="Userlocationofservice"></Field>

<Field Name="Userrequestno"></Field>

<Field Name="Userrequestdate"></Field>

<Field Name="Status"></Field>

<Field Name="Created By"></Field>

<Field Name="Modified By"></Field>

   </Method>

</Batch>

# December 3, 2007 1:45 PM

paras2020 said:

In the rules for the Submit button this is what I have:

Submit using a data connection: Web Service Submit

Query using a data connection: Add List Item Template

# December 3, 2007 2:34 PM

paras2020 said:

In the future I am going to be pulling in data from active directory to pre populate this fields. How would I do with a repeating table?? PLease advise.

# December 3, 2007 4:18 PM

paras2020 said:

I am using the method UpdateListItems in the web service. Thanks.

# December 3, 2007 4:25 PM

paras2020 said:

Hi Scott,

I also have the list I pointing to is workflow enabled....could that be causing the problem? Thanks

# December 4, 2007 11:38 AM

paras2020 said:

Is there away to adopt cascading menus to this infopath form??

Thanks.

# December 4, 2007 12:11 PM

mayankagarwal said:

Hi Guys

thanks for the great post, really helped a lot

If you can shed some light on how robust this method it.

For example if I add a new column to the list, and recreate my xml file, the sumbit function stops to work, it will give you that " form successfully submitted" but there are no entries in the list.

Also I have faced that this method works on one list and not the other, both the lists are done up exactly the day way.

Can you please suggest any ways to make the infopath form control datatype compatible with lists.

# December 4, 2007 9:42 PM

GLazkano said:

Hi Scott, I'm trying to update a sharepoint list field and I followed all the steps, but it doesn't write the sharepoint list.

There's no error or messages: it's simply not writting the data.

Is there a reason for that?

Thanks!

# December 5, 2007 7:41 AM

brandtsmith said:

One observation I had was that I needed to construct a custom list...and make the field names exactly as the AddListItemTemplate.xml...I was unable to submit to a OOTB MOSS Contact list...any suggestions?

??? tho - what if I want to submit a batch of say 350 items to the list? How do you construct the AddListItemTemplate.xml so that you can add additional items? (I'll actually populate my 'submit list' from a sql table-selectively)

# December 5, 2007 5:06 PM

sowmyasimha said:

Hi Scott,

Do all the fields in the table have to be Single Line Text. I would like to have some that are Rich Text (Multiple line) type columns from the sharepoint list included here. Is there some way I can do it?

Thanks!

Sowmya

# December 5, 2007 8:47 PM

infopath said:

Hello everyone,

I have been extremely busy lately with support issues so I will try to address your questions as soon as possible.

Scott

# December 6, 2007 8:07 AM

brandtsmith said:

Here is a support file that works with OOTB Contact list...with an additional field added as well...using 2 fields in the support file to get the field names to appear as I need...base field names for the submit don't change...just only display the 'DiaplyName' on th IP form...still want to submit multiples????

<?xml version="1.0" encoding="UTF-8"?>

<Batch OnError="Continue">

   <Method ID="1" Cmd="New">

 <Field Name="Account" DisplayName = "Account"/>

         <Field Name="Title" DisplayName = "Last Name"/>

         <Field Name="FirstName" DisplayName = "First Name"/>

         <Field Name="FullName" DisplayName = "Full Name"/>

         <Field Name="Email" DisplayName = "E-mail Address"/>

         <Field Name="Company" DisplayName = "Company"/>

         <Field Name="WorkPhone" DisplayName = "Business Phone"/>

         <Field Name="HomePhone" DisplayName = "Home Phone"/>

         <Field Name="WorkFax" DisplayName = "Fax Number"/>

         <Field Name="WorkAddress" DisplayName = "Address"/>

         <Field Name="WorkCity" DisplayName = "City"/>

         <Field Name="WorkState" DisplayName = "State/Province"/>

         <Field Name="WorkZip" DisplayName = "ZIP/Postal Code"/>

         <Field Name="Comments" DisplayName = "Notes"/>

   </Method>

</Batch>

# December 17, 2007 10:25 AM

infopath said:

Hi everyone,

Let's see if I can address some of these questions:

- paras2020: After adding the connection to your list, extract the files from your XSN (File -> Save as source files), open Manifest.xsf in Notepad and look at the SharePoint field names in this file...do they match exactly what you have in the embedded XML file?

-  mayankagarwal: Do the same steps noted above for paras2020 to make sure the names match. Also - review the comments from this blog...there are a number of other things you should confirm that have been discussed here previously.

-  GLazkano: Have you reviewed all the comments in this blog? There are a number of things to confirm: using the correct lists.asmx web service, insuring the field names in your XML file are spelled identical to the columns in your list, making sure there are no fields in your XML file that do not exist in your list, etc.

-  sowmyasimha: So far, I have not been able to get rich text type fields to work. I have not spent much time trying to find a workaround...if there is one. Unfortunately I have just not had time.

- For everyone that wants to submit multiple items: there may be a way to do this without code but I have not had any time to look into this. Currently the only way I have tested is with custom code: have a repeating node (i.e. a repeating table) on your View and use custom code to loop the items and add them to the list bu specifying the CAML query in your code.

Scott

# December 17, 2007 11:39 AM

GLazkano said:

Thanks for your reply.

I reviewed all the fields, all the things that could be wrong, and  everything is ok. If I change or modify the fields to another one it fails, but in my case it doesn't fail, it only doesn't do anything.

I reviewed the list.asmx and I'm using the correct list.

I'm really confused.

# December 20, 2007 5:52 AM

infopath said:

Hi GLazkano,

Do the column names in your SharePoint list contain any spaces? If so, then chances are the actual name is something like this in the connection: Test_x0020_Field.

However, if this is not the case then I would encourage you to open a support incident so someone can look into this further for you.

Scott

# December 20, 2007 8:01 AM

GLazkano said:

Hi,

The name of the sharepoint field I was trying to modify contains a space, but I changed it today and the field is now "Stock_virtual".

I've been working on it the entire morning, but it doesn't work.

How can I open a support incident?

Thanks

# December 26, 2007 7:19 AM

infopath said:

Hi GLazkano,

You can either call 800-936-5800 or start a support request here: http://support.microsoft.com/gp/assistsupport

I know I keep harping on this <G> but make sure you have checked the following:

- Your XML file does not contain any additional fields than what you have added as columns

- Those fields are spelled exactly as they are from SharePoint (to verify this, use the Save as Source Files option from the File menu and look at the field names in the manifest.xsf file)

- You are using the lists.asmx web service for the appropriate site you are using

- You have specified the correct list GUID

- Make sure this article does not apply: http://support.microsoft.com/kb/840549

- Have you renamed the "Title" field in your list? If so, this will still need to be referenced as "Title" in your XML file.

- Are there any errors in the Application Event log after submitting the data?

Scott

# January 2, 2008 8:33 AM

coleruiz said:

I tried this and it works well.

However, I found out the hard way that I can only have 5 fields on the list.   Also, you cannot have special characters or spaces on the field name.  

# January 15, 2008 5:57 PM

coleruiz said:

Ignore my comment about having maximum of 5 fields. InfoPath arbitrarily  rename my 5th field.  Checking the  manifest.xsf do not the correct names between sharepoint list and name specified on the XML.  

InfoPath truncates the field name if it's longer than 33 characters.

Very strange!

# January 15, 2008 7:10 PM

infopath said:

Hi coleruiz,

Glad to hear you were able to resolve the issue!

Scott

# January 21, 2008 8:18 AM

paul_g_ch said:

In the current senario I want to add some additional functioality :

I want to submit file attachment to the list library using this InfoPath form.

Please reply asap who is aware about how to do this.

Thanking all of our member

Gopal

# January 23, 2008 2:20 AM

Jdaskalis said:

Great Post.  I would love to create a repeating table that would allow managers throughout the country to submit timesheet entries for their staff.  Is it possible to do what you be in a repeating table format?  If so please point me in the right direction.  

Thanks

# February 1, 2008 10:52 AM

infopath said:

Hi Jdaskalis,

I have not been successful in implementing this functionality without writing code - if this is of interest to you, let me know and I will post the sample code.

Scott

# February 1, 2008 4:48 PM

Gmann001 said:

Hello! And thank you for the post, it's exactly what I've been looking for (and very detailed)!

I've followed the instructions exactly as listed and I am getting a SOAP error.  My form retrives data (that I've entered via Sharepoint) just fine, but it will not submit data via the form to my SharePoint list.

The error is...

"List does not exist"

"The page you selected contains a list that does not exist.  It may have been deleted by another user.  Click "Home" at the top of the page to return to your Web site."

I've checked, double-checked, and rechecked again the GUID, etc.

I even went as far as create a new SharePoint site just for this test and restarted your steps.  And once again I get the error. I also had the admin restart the server last night.... still no luck.

If it matters, I am using InfoPath 2007 and connecting to SharePoint 2003.

# February 7, 2008 1:18 PM

Gmann001 said:

Ok, here's another question...

Is there a way to do this without an XML (CAML) file?  That way the form is all "self-contained" in a single file?

# February 7, 2008 1:40 PM

Gmann001 said:

It figures I found my own solution right after I submit the question about the SOAP error.  It appears I had the wrong Web Service listed.  Since my site is a sub-site, I needed to use that service and not the one for the main (root) site.

I was using...

   /myServer/_vti_bin/lists.asmx

and should have been using...

   /myServer/sites/mySiteName/_vti_bin/lists.asmx

Thanks again for the great example!

# February 7, 2008 1:42 PM

infopath said:

Hi Gmann001,

I am glad you were able to get this working! Yes - you can do this without the XML CAML file - this was needed just to be able to add to a list without code. If you don't mind using code, you don't need this file. Look through the past comments here and you will see some sample code I provided for updating list items - this can also be used for adding items as well.

If you prefer to stay with the no code solution then that XML file is needed but keep in mind, it is indeed part of the solution - everything is in the one XSN file.

Scott

# February 7, 2008 4:24 PM

ArthurM said:

Scott,

I have followed the process you have created.  I hit the send button infopath states everything is working correctly. But everything is NOT working correctly.  The only Where on a server would be a error log for Sharepoint

# February 7, 2008 5:29 PM

infopath said:

Hi ArthurM,

Please make sure you review all comments in this post. A number of folks have run into the issue of getting a "successful" message and then nothing appearing in the list. There are a number of reasons why this may occur and that information is throughout this post.

Scott

# February 7, 2008 6:00 PM

Gmann001 said:

Hello again!  When looking at the post from October 19 (your sample code), I am unsure how "Create a new instance of our "Lists" web service"

Your code states..

server_Lists.Lists myList = new SubmitToSharePointList.server_Lists.Lists();

Since I am a starting VB programmer (due to company restrictions), my converted code looks like..

Dim myList As server_Lists.Lists = New SubmitToSharePointList.server_Lists.Lists()

It shows that there is no such thing as "server_Lists".  Am I missing something here?  Should I not be taking your code verbatim?  Is there something that I need to import/using (i.e. Imports System)?

I have a feeling this is a dumb question, but I am new to this and I'm having a heck of a time figuring it out.

Thanks again

# February 8, 2008 3:53 PM

Gmann001 said:

Is there a way that I can create a form that doesn't display the fields via a repeater table?  I need to create a form that has the look/feel as dictated by our legal department and unfortunately that look/feel is not a vertical table.  I need some fields horizontal to each other and I am required to place some text between other fields.

Basically I have a custom form that I would like to apply this method to.  Any help would be great...thanks!

# February 12, 2008 2:26 PM

infopath said:

Hi Gmann001 - in regard to the "lists" web service you will need to add a web reference to your code that points to the web service.

For the layout question - yes, what you can do is add a repeating table to your form with the appropriate fields. Then you will use code to either populate the fields in the Add List Item Template.xml file or simply build the CAML query in your code.

If you review some of my past comments, there is sample code for updating a list item - this is the same basic premise you would use for adding one as well.

Scott

# February 19, 2008 9:49 AM

pmdci said:

Hi there. I have a question which I hope someone can help me with.

What I would really like to do is to display two tables.

Both tables would display the items included in the SharePoint list (e.g.: the MyContacts list in the example above).

However, table 1 would show only items where the Boolean column MyColumn equals 0.

Table 2 would show only items where the Boolean column MyColumn equals 1. Plus, for each row there would be a checkbox.

Upon submitting the form, for every item ticked in table two would update the MyColumn column in SharePoint. Thus updating the list of TABLE 1.

Is this possible to be done, without coding? I am a little bit rusty with InfoPath these days but I think this could be possible with the use of filters and conditionals?

Thank you a lot in advance!

Regards,

P.

# March 13, 2008 12:43 PM

infopath said:

Hi pmdci,

What you are trying to accomplish would require custom code. As you have probably read in the comments on this post, InfoPath is not able to submit to a SharePoint list out of the box. You can "add" items without code but to edit/delete an existing item it requires custom code.

Scott

# March 14, 2008 11:30 AM

SharePoint Consultant / InfoPath Consultant said:

A good post for anyone starting to use InfoPath.

# March 18, 2008 7:18 AM

saefeldin said:

Nice Post.

i works perfectly.

but how can i use other field types(drop-down menu, people and groups, etc...) in this info path form ??

i used this post in Task list and it works just fine, but "Assigned to" field in the form i write numbers not names to get a result !!!

i think this is the id of the users or groups.

how can i get users from my domain in assigned to field ??

appreciate any help.

# April 14, 2008 7:26 AM

infopath said:

Hi saefeldin,

You are correct - you will need to pass in the SharePoint ID of the user so that it will resolve to the domain\user value. The only way I know of to do this is to either write the code behind InfoPath or create a small custom web service that takes the domain name and returns the SharePoint User ID. Here is a sample web service that I have used to get this information; however, it is important to note that in doing this I have only been successful in using code behind InfoPath to add tasks - in other words, this is *not* a codeless solution:

[WebMethod]

   public int GetUserID(string strSite, string strDomainUser)

   {

       if (strDomainUser != "")

       {

           SPSite site = new SPSite(strSite);

           SPWeb web = site.OpenWeb();

           SPUser user = web.AllUsers[strDomainUser];

           return user.ID;

       }

       return 0;

   }

If you review prior comments you will see sample code I have provided to "update" existing contacts. This is the same basic code that would be used to "add" a new task programmatically - you would just need to incorporate something like the above so you can set the "AssignedTo" field to a valid SharePoint ID.

Scott

# April 14, 2008 8:34 AM

m181354 said:

The example above worked great but now I want to create a CAML for my list and I can not get it to work unless I use the CAML created in the example above.  My CAML looks like the following.  Do yoiu know why.  I have started from scratch with a new form and a new custom list.

<?xml version="1.0" encoding="UTF-8"?>

<Batch OnError="Continue">

   <Method ID="1" Cmd="New">

       <Field Name='Title'></Field>

       <Field Name="TaskNo"></Field>

       <Field Name="TaskDescription"></Field>

       <Field Name="ProcurementTravel"></Field>

       <Field Name="LaborEstimate"></Field>

   </Method>

</Batch>

# May 9, 2008 2:58 PM

infopath said:

Hi m181354,

You will want to verify the following items:

- Your list GUID is correct

- Your "Lists.asmx" web service data connection is referenced at the correct level (i.e. http://server versus http://server/site)

- Your XML file does not contain any additional fields than what you have added as columns

- Those fields are spelled exactly as they are from SharePoint (to verify this, use the Save as Source Files option from the File menu and look at the field names in the manifest.xsf file)

- Make sure this article does not apply: http://support.microsoft.com/kb/840549

- Have you renamed the "Title" field in your list? If so, this will still need to be referenced as "Title" in your XML file.

Scott

# May 9, 2008 3:29 PM

m181354 said:

My manifest.xsf file has the wrong Sharepoint names in them but the correct Infopath names. I have the right GUID and the correct "Lists.asmx" web service data connection.  I do not know why the Sharepoint names still match the names fom the example above.   See below

<xsf:dataObject name="JDAM Task List" schema="JDAM Task List.xsd" initOnLoad="yes">

<xsf:query>

<xsf:sharepointListAdapter siteUrl="https://tcc.web.boeing.com/jdam/JDAM/" sharepointGuid="{0F7220FC-E894-4523-9043-6F6B367A339F}" infopathGroup="JDAM_Task_List" queryAllowed="yes" submitAllowed="no" name="JDAM Task List">

<xsf:field sharepointName="Title" infopathName="Title"></xsf:field>

<xsf:field sharepointName="FirstName" infopathName="Task_No"></xsf:field>

<xsf:field sharepointName="LastName" infopathName="Task_Description"></xsf:field>

<xsf:field sharepointName="Email" infopathName="Procurement_Travel"></xsf:field>

<xsf:field sharepointName="Phone" infopathName="Labor_Estimate"></xsf:field>

</xsf:sharepointListAdapter>

</xsf:query>

</xsf:dataObject>

# May 9, 2008 6:59 PM

infopath said:

Hi m181354,

What you may want to try is deleting the connection from Tools -> Data Connections and then re-adding that connection back. I don't know that I have ever seen that behavior before where the XSN did not pick up the correct fields - that is odd.

Scott

# May 12, 2008 7:16 AM

cmf6868 said:

Hi Scott,

I am trying to follow the steps you have included in your article and am having a problem with #4 in Step 6: Add the "lists.asmx" web service. When I double-click the "updates" parameter, I see the same thing listed as for the "listname" parameter and not the "Add list Item Parameter" data source as is specified in #4. Do you have any idea as to what I have done wrong?

Thank you.

# May 15, 2008 3:38 PM

infopath said:

Hi cmf6868,

When you double-click the "updates" parameter, by default, you will see what nodes are in the "Main" data source. There is a "Data Source" drop down box at the top - click this and select "Add List Item Template."

Scott

# May 16, 2008 8:43 AM

cmf6868 said:

I got it Scott! Thank you so much for your help and your excellent article!!!

# May 20, 2008 2:50 PM

infopath said:

Excellent! :)

Scott

# May 20, 2008 3:36 PM

alpha_geek said:

Hi Scott,

Thanks for the info on this, but I am still struggling. I am a victim of the successful submit but no data issue.

I can get the example to work no problem, so I have moved on to my own form (a purchase order form).

This form contains a series of fields, and a repeating table. The information outside of the repeating table is to be submitted to "list1" and the data inside the repeating table is submitted to "list2".  The code for submitting the 2 lists is identical (bar variable names), and list1 is submitted before list2.

List2 works without error, but no matter what I do I can't get list1 to work. I have verified the GUID, the webservice path, the defined fields in the XML and the spelling and case. The MS KB does not apply to me. I have compared my list1 and list2 and found no difference in the way they are set up.

None of the field names have spaces, but when I check the manifest.xsf I can find the references to the fields but all of them have spaces in them. This is true for both list1 and list2 !?! Can you provide a little more info regarding the manifest.xsf and how to correct problems if they are found? I take it I can't just edit the file and save it back?

I have been at this for 3 days, and I am at a loss. If it was not for the fact that one list works but the other does not, I would have thought it was me.

Thanks again

# June 5, 2008 11:44 AM

infopath said:

Hi alpha_geek,

Are you using code or just the default "add" like the sample? Also - can you describe your data source and lists and let me try to repro?

Scott

# June 10, 2008 8:05 AM

callumbundy said:

Hi Scott,

Brilliant article, worked perfectly for me. The next thing I want to do however is combine this infopath submit function with the data gathered from the users MOSS profile (This Article: http://blogs.microsoft.co.il/blogs/itaysk/archive/2007/04/05/InfoPath-_2D00_-Get-the-current-user-without-writing-code.aspx )

Basically what I need to be able to do is to collect users infomation from MOSS (no problem) and then submit that same infomation back into a sharepoint list, with some additional user input fields.

Any idea how I might be able to achieve this?

# July 3, 2008 9:32 AM

infopath said:

Hi callumbundy,

You will need to get the data from the User Profile into fields in your main DOM. If you only return information for one user then you could use either Rules or the Default Value property to pull the data from the User Profile result into your main DOM. Then I would expect it to be basically like the sample...unless I am missing something?

Scott

# July 7, 2008 4:25 PM

infopath said:

Hi callumbundy,

You will need to get the data from the User Profile into fields in your main DOM. If you only return information for one user then you could use either Rules or the Default Value property to pull the data from the User Profile result into your main DOM. Then I would expect it to be basically like the sample...unless I am missing something?

Scott

# July 7, 2008 4:25 PM

arosoccer said:

Scott,

Thanks for your help so far. I am looking to attach the .xml file that would be generated on a "Submit to Sharepoint Document Library" to the list item that form generates. How would I go about doing that? I can use the

XPathNavigator myNavigator = this.MainDataSource.CreateNavigator();

string wholeXML = myNavigator.OuterXml.ToString();

to get the XML representation of the form. I'm just not sure how to make it an attachment on the Sharepoint list.

Thanks in advance,

Andrew

# September 11, 2008 3:44 PM

infopath said:

Hi Andrew,

Unfortunately I don't know how to programmatically create a SharePoint list attachment. You may want to ping one of the SharePoint blogs as this is not InfoPath specific. For instance, you could really just write some code behind a Windows form that grabs an XML file and now you need to att this as a List attachment.

I am sorry I don't have a better option for you.

Scott

# September 11, 2008 6:02 PM

hollyanne said:

Hi Scott,

Thank you for this great demo.  I have used it in a purchase request form to populate a vendor drop-down.    It works great.  Now I would like to use the same idea to update an Expense number field.  

I want to take a field that is automatically populated upon opening the form and send it to a different sharepoint list.  Rather than opening a form that I need to fill in, can I send an already populated field to a sharepoint list?  It seems like it should be easy to do, but I havent figured it out yet.

Thanks

Holly

# September 14, 2008 11:54 AM

infopath said:

Hi Holly,

Before I address the question, I need to be sure I understand what you need: so you open an InfoPath form and upon opening, some field is automatically populated. When you then submit that form to a list, you *also* want to submit just that auto-populated field to another list as well?

Am I understanding correctly?

Thanks,

Scott

# September 15, 2008 7:41 AM

hollyanne said:

Hi Scott,

Yes, except that I want the field to be sent to the list immediately after the field is populated.  

I have my purchase request form and a secondary sharepoint list called PR# with a field called eNumber.  Right now I am using the following to populate a field upon opening the form;

max(eNumber) + 1  

I would like the next rule to immediately submit the number back to the PR# list so that it is available the next time the form is open.  Basically an autonumber.

Thanks

Holly

# September 15, 2008 10:10 AM

infopath said:

Hi Holly,

OK - Based on my understanding, I have this working, I believe, as you need. Here are the changes I made to my sample XSN:

- Created a new "Add List Item Template" XML file like this:

<Batch OnError="Continue">

   <Method ID="1" Cmd="New">

       <Field Name='Title'></Field>

       <Field Name="eNumber"></Field>

   </Method>

</Batch>

- Saved this as: Add List Item Template_PRNumber.xml"

- Created a new "Receive" data connection to this XML file, chose to include this as a Resource file and set this to retrieve the data when the form opens

- Added another "Receive" data connection to my PRNumber list and included the "Title" and "eNumber" fields

- Added a new field to my main data source called: ListName_PRNumber and set the default value of this to the list GUID of my PRNumber list (same steps as when you set the "ListName" field from this sample)

- Added a new "Submit" data connection just like the one in the sample except I am using the "ListName_PRNumber" field for the ListName and the "updates" parameter points to the "Batch" node from my new Add List Item Template_PRNumber file

Now, for the field in my main data source that is to store and display the incremented number, I am not using the "default value" for this field - I am using a Rule on the form open so that this will only fire if that field is blank. So if the field is blank, I have the following actions:

- Set a field's value

    - Field: field in my main data source to store the new value

    - Value: max(@eNumber) + 1

- Set a field's value

    - Field: this is the "Field" node from the Add List Item Template_PRNumber connection (not the "name" field - just select the "Field" repeating node)

    - Value: I selected the field from the above step that stores the new value

NOTE: When setting the above "Field" it is going to set both the eNumber and Title fields to the newly incremented value. There is no getting around this unless you use code. For my sample, this is fine...it just means the title is the same value as eNumber.

- Submit using a data connection

    - The data connection is the new submit connection back to the PRNumber list

So in my testing, when I double click the XSN, the field in my main data source is blank so the Rule kicks off and sets that value to the max value from the PRNumber list + 1. That rule then sets the "Field" node in the new Add List Item Template_PRNumber connection to this newly incremented value and submits it back to the PRNumber list.

I do have some concerns about this method: if you have a lot of new forms being created, then this list is going to get big relatively quickly. I am not a SharePoint expert so you may want to see if there will be a performance issue if the PRNumber list grows to, say, 1000-2000 items.

I hope this helps!

Scott

# September 15, 2008 11:31 AM

hollyanne said:

Hi Scott,

It worked like a charm.  I will be setting up a workflow to clean up the enumber list after it reaches 100 since I only need it for the autonumber feature.

Thank you very much

Holly

# September 15, 2008 5:57 PM

infopath said:

Hi Holly,

That's great to hear!

Scott

# September 16, 2008 7:56 AM

levar said:

Hello Scott,

Thank for your article it's really great.

I tried you method on the simple list and it works, but when I try to use it on the task list it doesn't work. Publishing is successful, but the item doesn't appear. Is there any difference between list and task, as I know task is list to.

Thanks in advance!

# September 16, 2008 8:06 AM

infopath said:

Hi levar,

I have been able to get this to work but there are a few caveats:

1) The "AssignedTo" column *must* be the SharePoint ID for the user

2) The "Status" column needs to be entered as the textual value (i.e. Not Started)

3) The "Priority" column needs to be entered as the textual value (i.e. (2) Normal)

4) Any date fields need to be entered in the format of: yyyy-mm-dd (for en-US anyway <G>) So as an example: 2008-09-17

Here is what I have tested in my Add List Item Template XML file:

<Batch OnError="Continue">

   <Method ID="1" Cmd="New">

       <Field Name='Title'></Field>

       <Field Name="AssignedTo"></Field>

       <Field Name="Status"></Field>

       <Field Name="Priority"></Field>

       <Field Name="DueDate"></Field>

       <Field Name="StartDate"></Field>

       <Field Name="PercentComplete"></Field>

   </Method>

</Batch>

And here are sample values I have entered for each - in the same order as above:

Test1

1

Not Started

(2) Normal

2008-09-17

2008-09-16

.50

NOTE: The "1" above for AssignedTo again is my SharePoint ID. This is where it could get a bit tricky. The way I have done this (and there may be better ways that I don't know of) is I have a custom web service on my WFE that accepts the domain name of the current user and returns the user ID:

[WebMethod]

   public int GetUserID(string strSite, string strDomainUser)

   {

       if (strDomainUser != "")

       {

           SPSite site = new SPSite(strSite);

           SPWeb web = site.OpenWeb();

           SPUser user = web.AllUsers[strDomainUser];

           return user.ID;

       }

       return 0;

   }

However, even once you have this there is not a simple way to set this up for this sample as the ultimate way to do this would be, say, have a dropdown box for the "AssignedTo" field and when you select the user it actually stores the SharePoint ID.

This is one of the cases where the better option may be to use code instead of the steps in this initial sample.

I hope this helps!

Scott

# September 16, 2008 9:41 AM

levar said:

Hi Scott,

Thanks a lot it was great help!!!

# September 17, 2008 3:51 AM

infopath said:

Hi levar,

Glad to help!

Scott

# September 17, 2008 7:13 AM

Nathu said:

Hi

does this work with Windows sharepoint services 3.0 Also ?

Narsinh

# September 29, 2008 10:34 AM

infopath said:

Hi Narsinh,

I've never tried on a WSS only server but I don't believe there is any reason why this would not work...assuming the "lists.asmx" web service is a part of WSS.

Scott

# September 29, 2008 11:53 AM

Nathu said:

Scott

I had followed every thing mention you above article .

but not new item doesn`t add to list . where if I add manually new Item it does Query and able to see that

any help

Narsinh

# September 30, 2008 2:52 AM

infopath said:

Hi Narsinh,

I know there are a lot of comments on this post but have you gone through all of these? There are a number of reasons why the entry may fail to appear and most of these have been covered in these comments.

Scott

# September 30, 2008 7:59 AM

Nathu said:

Hi Scott

IS any where logs get generated to check out  what getting wrong .

Actually I wants create few forms new joinees which get mail to resptive group as well as store inform store in list

so that same can be used various places .

I had tried with your example but it just message it got submitted but does show item in the list

Pls help

Narsinh

# September 30, 2008 1:24 PM

Nathu said:

Hi Scott

Great news it work your sample list  for me on old test site. it seems there some problem with title flied.

Thanks for you artlicle .

will trouble if need any help for actuall site implementation

Thanks

Narsinh

# September 30, 2008 2:53 PM

infopath said:

Hi Narsinh,

I don't believe this is logged anywhere in SharePoint. Did you actually look through the various posts on this site? There are various reasons why you are seeing this behavior and I personally have seen and covered those here in this post.

Scott

# September 30, 2008 2:55 PM

JeffTemple said:

Hi Scott,

Thanks for the helpful article and following up on the postings.  I have completed the fields but have the following issue.

My submit fires correctly and creates a row in the sharepoint list.  It however is completely blank.  None of the data is carried from the form into the SP list.

Any Ideas??

An InfoPath Newbie

Jeff

# October 13, 2008 1:02 PM

suz7777 said:

great post, it worked the first time.  Is it possible to show the field description in the infopath form?  How would I define this in the xml?

thank you!

suz

# October 15, 2008 2:42 AM

infopath said:

Hi Jeff,

A few things to check:

- Make sure your XML file contains only those column names you added - if there is a column in the XML file that does not exist it will cause a problem.

- Make sure the names you specified are spelled correctly (including capitalization)

- With the columns that you added in SharePoint - did you include spaces in the name? If so - it's not as simple as just adding spaces in the name in your XML file (to see how the names come into InfoPath, create a new XSN with a receive connection to your list. Then from the File menu choose Save As Source Files and look in the manifest.xsf file.)

Suz - glad this has worked for you! In regard to how to get the "Description" field - oddly enough the actual SharePoint name of this field is: "Body" - with a captial "B." This is what you will need to add to your XML file. :)

Scott

# October 15, 2008 2:04 PM

emumu said:

Sorry to repost since I have not seen the first message I posted yesterday...

I got an error message saying the GUID should be 32 digits with 4 dashes. And, I double checked the GUID in the URL of the SharePoint list and it was way more than 32 digits and has 5 dashes.

Any thoughts? Thanks. -ET

# November 4, 2008 3:00 PM

infopath said:

Hi ET,

It sounds like you may be using the "encoded" version of your list GUID. Here is what you need to do:

- Navigate to your list

- From the Settings button choose List Settings

- You should see something like this in your address bar:

List=%7B1E76517B%2D2C36%2D4473%2DA420%2DA737D98589BC%7D

- What you want is the portion after "List="

%7B1E76517B%2D2C36%2D4473%2DA420%2DA737D98589BC%7D

- Now, you need to "decode" this GUID as follows:

%7B = {

%7D = }

%2D = -

- So if you replace the encoded characters as described, you end up with this, which has 32 characters and 4 hyphens.

{1E76517B-2C36-4473-A420-A737D98589BC}

Scott

# November 5, 2008 9:46 AM

dishaniti said:

Hello

In my form library, I am have enabled - email enabling list, where user email infopath form and it automatically adding in to form library. It is working very nicely. Now I want to extent this feature for some users where user will mail an XML  file in different format which is not same as form library have. I want to transform their XML into infopath XML format. I  just need a way to accept the XML and then use the XSLT to create a the form in predefined form template on MOSS and upload it to the SharePoint site.

Is this possible?

Disha

# November 11, 2008 9:16 AM

infopath said:

Hi dishaniti,

Just a thought: either create code on a SharePoint event handler to do this or create a custom web service that takes the XML, performs your modifications to the file and then pushes the "fixed" file back to the library.

If you need direction on using a SharePoint event handler I would encourage you to post that request to a SharePoint forum or blog as I don't want to steer you in the wrong direction. :)

Scott

# November 11, 2008 11:38 AM

auropravin said:

Hi Scot,

I need to add a drop down list, a calendar and rich text box along with the normal fields to update my custom list.

What is the solution for it.?

Requirement is quite urgent

please respond

# November 18, 2008 4:31 AM

infopath said:

Hi auropravin,

The only way you will be able to do this is to use custom code. If you did not need the rich text capabilities we could still do this without code; however, with this requirement the only way to accomplish this is via code.

The steps are basically the same as in this sample; however, here are the modifications you need to implement:

1) My list is called: TestList and consists of the following field names and data types:

txtName, Single line of text

txtDropDown, Single line of text

txtDate, Date and Time

txtRichText, Multiple lines of text (rich text selected)

2) My Add List Item Template.xml file is as follows:

<?xml version="1.0" encoding="UTF-8"?>

<Batch OnError="Continue">

   <Method ID="1" Cmd="New">

       <Field Name='Title'></Field>

       <Field Name="txtName"></Field>

       <Field Name="txtDropDown"></Field>

       <Field Name="txtDate"></Field>

       <Field Name="txtRichText"></Field>

   </Method>

</Batch>

3) Instead of adding the "Add List Item Template" fields to your View, you will need to create your own data structure in the main DOM. This is what I am using as a sample:

myFields

    ListName

    gpTestList (Group)

         _Title (string)

         _Name (string)

         _Dropdown (string)

         _Date (string!)

         _RichText (XHTML)

4) Drag "gpTestList" to your view as a Section with Controls

5) Change the "_Dropdown" text box to a Dropdown control

6) Change the "_Date" text box to a DatePicker control and set the Format to just display the date

7) Add a button control (for the submit process) and you will use code like this on the click event (note you need to use the "InnerXml" property when setting the rich text value!):

XmlNamespaceManager ns = this.NamespaceManager;

//Create a DataSource object for the Add List Item Template data source

DataSource dsAddListItem = this.DataSources["Add List Item Template"];

//Create an XPathNavigator object for that data source

XPathNavigator xnAddListItem = dsAddListItem.CreateNavigator();

//Create an XPathNavigator object for the main DOM

XPathNavigator xnDoc = this.MainDataSource.CreateNavigator();

//Create XPathNavigator objects for each of our fields in the main DOM

XPathNavigator xnTitle = xnDoc.SelectSingleNode("/my:myFields/my:gpTestList/my:_Title", ns);

XPathNavigator xnName = xnDoc.SelectSingleNode("/my:myFields/my:gpTestList/my:_Name", ns);

XPathNavigator xnDropdown = xnDoc.SelectSingleNode("/my:myFields/my:gpTestList/my:_Dropdown", ns);

XPathNavigator xnDate = xnDoc.SelectSingleNode("/my:myFields/my:gpTestList/my:_Date", ns);

XPathNavigator xnRichText = xnDoc.SelectSingleNode("/my:myFields/my:gpTestList/my:_RichText", ns);

//Set the values of each field in the Add List Item Template data source to the

//values from the main DOM

xnAddListItem.SelectSingleNode("/Batch/Method/Field[1]", ns).SetValue(xnTitle.Value);

xnAddListItem.SelectSingleNode("/Batch/Method/Field[2]", ns).SetValue(xnName.Value);

xnAddListItem.SelectSingleNode("/Batch/Method/Field[3]", ns).SetValue(xnDropdown.Value);

xnAddListItem.SelectSingleNode("/Batch/Method/Field[4]", ns).SetValue(xnDate.Value);

xnAddListItem.SelectSingleNode("/Batch/Method/Field[5]", ns).SetValue(xnRichText.InnerXml);

//Submit the data

this.DataConnections["Web Service Submit"].Execute();

When I test this, the data submits correctly including rich text data (i.e. I bolded some text, changed the font color of other text, etc.)

I hope this helps!

Scott

# November 18, 2008 9:54 AM

jamiehook01 said:

Hello,

I have created this form and it works fine within infopath but when it is published to a document library it will open and retrieve data but throws an error when it is submitted.

This is just a generic error.

Can any one help????????

# November 19, 2008 10:31 AM

jamiehook01 said:

Just an update to my above comment i have also tried this suggestion but it gave the same error.

____

Tuesday, September 11, 2007 4:01 PM by infopath

Hi Brian,

I just tested this process after pubishing my XSN as a Site Content Type and it worked from the browser without issue.

If you would, try these steps:

- Delete the Content Type from the document library where you added the published content type

- Delete it from the Site Content Type list

- Delete the XSN from the saved location

- Create a new library on the same site called: ContentTypes

- Publish the XSN as a Site Content Type and save it in the ContentTypes library

- Add it as a Content Type to your document library

- Test

Scott

_____

# November 19, 2008 11:16 AM

infopath said:

Hi jamiehook01,

What you will need to do to debug this is enable Verbose logging on your server for the Forms Services categories, reproduce the error and then check the ULS logs on the server - these should provide you direction on why it fails.

Scott

# November 20, 2008 6:22 PM

Fishman4 said:

Hello Scott.

IRT this post "Monday, October 08, 2007 9:42 AM".

I have followed the tutorial on how to add to a sharepoint list and it works beautifully.  Naturally, that was not enough and I needed to update and delete.  After further reading, I found your later entry addressing this and I have hit some snags.  I copied your code into my form, but I am getting some build errors.  It is probably just some syntax, but I am not a programmer and I am struggling.  I get these two errors:

The name 'e' does not exist in this context.

The type or namespace name 'serverName' could not be found (are you missing a using directive or an assembly reference?)

Here is my code:

public void InternalStartup()

       {

           ((ButtonEvent)EventManager.ControlEvents["UpdateList"]).Clicked += new ClickedEventHandler(UpdateList_Clicked("Update", e.Source.CreateNavigator()));

       }

       public void UpdateList_Clicked(string strOperation, XPathNavigator e)

       {

      {

          //Create a new instance of our "Lists" web service

          serverName.Lists myList = new serverName.Lists();

          //Pass the logged on users credentials to the web service

          myList.Credentials = System.Net.CredentialCache.DefaultCredentials;

          //Create a DataSource object for our list data source

          DataSource dsContacts = this.DataSources["MyContacts"];

          //Create a NamespaceManager object so we can use the various namespaces on our XPATH expressions

          XmlNamespaceManager ns = this.NamespaceManager;

          //Create XPathNavigator objects for each field from our list

          XPathNavigator xnID = e.SelectSingleNode("@ID", ns);

          XPathNavigator xnFirstName = e.SelectSingleNode("@FirstName", ns);

          XPathNavigator xnLastName = e.SelectSingleNode("@LastName", ns);

          XPathNavigator xnTitle = e.SelectSingleNode("@Title", ns);

          XPathNavigator xnEmail = e.SelectSingleNode("@Email", ns);

          XPathNavigator xnPhone = e.SelectSingleNode("@Phone", ns);

          //Create a new XmlDocument to use for specifying the Update CAML query

          XmlDocument doc = new XmlDocument();

          //Create the needed update element

          System.Xml.XmlElement updates = doc.CreateElement("Batch");

          //Create the CAML query passing in the value of each of our fields from the form

          if (strOperation == "Delete")

          {

              updates.InnerXml = string.Format(@"<Method ID='1' Cmd='Delete'>" +

              "<Field Name='ID'>" + xnID.Value + "</Field>" + "</Method>");

          }

          else

          {

              //Create the CAML query passing in the value of each of our fields from the form

              updates.InnerXml = string.Format(@"<Method ID='1' Cmd='Update'>" +

              "<Field Name='ID'>" + xnID.Value + "</Field>" +

              "<Field Name='FirstName'>" + xnFirstName.Value + "</Field>" +

              "<Field Name='LastName'>" + xnLastName.Value + "</Field>" +

              "<Field Name='Title'>" + xnTitle.Value + "</Field>" +

              "<Field Name='Phone'>" + xnPhone.Value + "</Field>" +

              "<Field Name='Email'>" + xnEmail.Value + "</Field>" + "</Method>");

          }

          //Update the list

          XPathNavigator xnListGUID = this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:ListName", ns);

          XmlNode node = myList.UpdateListItems(xnListGUID.Value, updates);

          //Requery the data source to reflect the updates

          dsContacts.QueryConnection.Execute();

      }

Sorry for resurrecting something kinda old, but it would greatly improve my quality of life!  Thanks in advance for your assistance.

Don F.

# November 24, 2008 11:13 AM

infopath said:

Hi Don F,

The "serverName" issue is most likely caused by either not having added a "web reference" to the "Lists.asmx" web service or you added it and you need to change "serverName" to whatever name you entered for ther web reference.

In regard to the "e" error, it looks like you have one too many opening braces ("{") after "private void".

Now, also - the way I wrote this code (if you want to follow it exactly) would be as follows:

- Assuming you have a button with the ID of: UpdateList, then the *only* line of code you should have in its "clicked" event is this:

UpdateList("Update", e.Source.CreateNavigator());

Then you need the "UpdateList" procedure as follows:

public void UpdateList(string strOperation, XPathNavigator e)

      {

           //Create a new instance of our "Lists" web service

           sheimserver.Lists myList = new sheimserver.Lists();

           //Pass the logged on users credentials to the web service

           myList.Credentials = System.Net.CredentialCache.DefaultCredentials;

           //Create a DataSource object for our list data source

           DataSource dsContacts = this.DataSources["MyContacts"];

           //Create a NamespaceManager object so we can use the various namespaces on our XPATH expressions

           XmlNamespaceManager ns = this.NamespaceManager;

           //Create XPathNavigator objects for each field from our list

           XPathNavigator xnID = e.SelectSingleNode("@ID", ns);

           XPathNavigator xnFirstName = e.SelectSingleNode("@FirstName", ns);

           XPathNavigator xnLastName = e.SelectSingleNode("@LastName", ns);

           XPathNavigator xnTitle = e.SelectSingleNode("@Title", ns);

           XPathNavigator xnEmail = e.SelectSingleNode("@Email", ns);

           XPathNavigator xnPhone = e.SelectSingleNode("@Phone", ns);

           //Create a new XmlDocument to use for specifying the Update CAML query

           XmlDocument doc = new XmlDocument();

           //Create the needed update element

           System.Xml.XmlElement updates = doc.CreateElement("Batch");

           //Create the CAML query passing in the value of each of our fields from the form

           if (strOperation == "Delete")

           {

               updates.InnerXml = string.Format(@"<Method ID='1' Cmd='Delete'>" +

               "<Field Name='ID'>" + xnID.Value + "</Field>" + "</Method>");

           }

           else

           {

               //Create the CAML query passing in the value of each of our fields from the form

               updates.InnerXml = string.Format(@"<Method ID='1' Cmd='Update'>" +

               "<Field Name='ID'>" + xnID.Value + "</Field>" +

               "<Field Name='FirstName'>" + xnFirstName.Value + "</Field>" +

               "<Field Name='LastName'>" + xnLastName.Value + "</Field>" +

               "<Field Name='Title'>" + xnTitle.Value + "</Field>" +

               "<Field Name='Phone'>" + xnPhone.Value + "</Field>" +

               "<Field Name='Email'>" + xnEmail.Value + "</Field>" + "</Method>");

           }

           //Update the list

           XPathNavigator xnListGUID = this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:ListName", ns);

           XmlNode node = myList.UpdateListItems(xnListGUID.Value, updates);

           //Requery the data source to reflect the updates

           dsContacts.QueryConnection.Execute();

       }

Scott

# November 24, 2008 11:49 AM

Arghhhh said:

Hi,

I've read this page and I'm not sure if it can help me to do what i have to do.

I explaine : I have a SPS2003 form library that I have to migrate to a WSS 3.0 list.

The forms have attachment inside them.

The goal is to populate columns of the list with the datas that are in the form and have the form attachement attached to the list......

Is it possible ?

Regards.

# December 2, 2008 10:02 AM

infopath said:

Hi,

There are a couple of "hurdles" you are going to need to address for this to work:

#1: Attachments in an InfoPath form are base64 encoded - to extract them you need to use custom code (unless you want to manually open each form and save out the file.) Here is a Knowledge Base article to get you started:

892730: How to encode and decode a file attachment programmatically by using Visual C# in InfoPath 2003 Service Pack 1

http://support.microsoft.com/default.aspx?scid=kb;EN-US;892730

** NOTE: The code in this article was specific to InfoPath 2003. If you are using the new 2007 object model with VSTA, you will need to convert this code.

#2: Once you extract the file now you need to get it to the appropriate item in your list. The SharePoint "Lists" web service has an "AddAttachment" web method that will allow you to attach a file to a list item so this may be of help.

However, if you run into any issues using the web service a SharePoint group will be a better option for assistance.

Scott

# December 3, 2008 3:51 PM

EricL said:

Hi,

This is almost exactly what I needed.  I implemented your solution to make sure it was working and it does add new items to my list.  That's not quite what I need to do.

I've ready all the posts on updating an existing list item, but I think my needs are somewhat simpler and am hoping you can simplify for me?  I use a lot of C# code-behind so that part won't be a problem.

I feed-in an SP List of 'variables' which allows me to dynamically control behavior within the code.

My form submissions are done programmatically based on "OnClick" events.

Just before submitting the form, I'd like to update just one of my variables which is stored in the 'variables' SP List.  I'd like to do it completely behind the scenes.  It's just a counter for certain actions taken by the user.  

So I'm wondering how much of your original solution can be eliminated if I merely need to update one existing item with each submit?

I could go ahead with your suggested "update" code, but I see it involves having buttons for each list item.  My list item is always the same thing (and invisible to the user) with just a varying value being sent to it automatically.

Thanks for any help you can provide!

--Eric

# December 8, 2008 1:36 PM

infopath said:

Hi Eric,

I would say just to use the basic code I have here in these comments for doing the "update." The only reason I used a button in the repeating table is so that you could determine which list item you were updating. If you are updating the same one all the time then you can just hard-code the list item ID.

Scott

# December 8, 2008 2:42 PM

EricL said:

Hi Scott,

Thanks for your reply!  I setup a new solution and am trying the basic update process you've listed above.

I think I'm in trouble.  So far all my coding in the InfoPath code-behind has been done with VS2003 (and until recently against SP2003 sites).  Now our sites are SP2007, but we're still using VS2003 which has been working OK.

In order to use the XPATHNAVIGATOR, do I need to upgrade to VS2005 (.net 2.0)?  I don't seem to find a reference to it from within VS2003 but maybe I'm missing something?

Also, we have a thousand or so documents in the site I'm working with.  Will it require updates to all the existing documents if we move to VS2005?

Any other concerns with upgrading to use VS2005 at this point?

Thanks and sorry for my ignorance on this.  I know there's obvious advantages for upgrading - it's just we run very lean so tend to wait until necessary.  I noticed we could start passing variables into InfoPath via the URL string if we were on VS2005 too.  That would be helpful.

--Eric

# December 9, 2008 12:05 PM

pcorrell said:

I have a question. I have an Infopath 2007 form for submitting expenses. The completed form is submitted to a SharePoint Library. No problem there. Depending on the type of expense, specific individuals have to approve the expense.

I want to create a workflow, based on the type of expense, to feed to the specific individuals for their approval. How can I address this in the Infopath form, and how can the submission kick off the workflow?

PC

# December 9, 2008 3:18 PM

Arghhhh said:

@Infopath

Hi,

if I put aside the attachment problem....does this work with existing forms ?

I mean even if I change the template.xsn using this method, will the forms already created be modified ? How to pupolate the list using the form : do I have to open the one by one to submit them to the list ?

Sorry if my questions seems dumb but it is quit non obvious to me :(

Regards

# December 10, 2008 7:55 AM

infopath said:

EricL:

Yes - the "XPathNavigator" object is new so you will need to either migrate and use Visual Studio Tools for Applications (behind InfoPath) or Visual Studio 2005 or convert the code in this post to the older object model.

In regard to "thousands of documents? - are you referring to XSN or XML files? If the thousands of documents are completed XML files and are all bound to the same XSN, then once you make the code change in the XSN the existing XML files will be updated automatically (assuming you have not changed the default behavior) once they are opened.

Pcorrell:

There is no true "workflow" capabilities in InfoPath. You can attach a workflow to an InfoPath form or you would typically use InfoPath forms in your workflow (i.e. the Init form, Association form, etc.) However, workflows are created in either SharePoint Designer or Visual Studio and support for these are handled through the SharePoint team. So I am not trying to "push you away" but I do very little with workflows here in the InfoPath group and would suggest you post that question to a SharePoint/Workflow group.

Arghhhh:

Ok - let's forget the attachment part of the question for a moment. You have an existing "library" that contains completed InfoPath XML files - correct? And now what you want/need to do is take the "data" that is in each of those files and migrate/move/copy to a new SharePoint "list" - correct?

So assuming my understanding is correct there is nothing built-in to InfoPath that would facilitate this. First off - you can not "submit" InfoPath forms/data directly to a SharePoint list...hence the reason for this post. So you will need to either:

- Implement this solution in the XSN that was used for all the completed InfoPath XML forms and open each one and  submit the form to the list

- See if there is some type of SharePoint code solution that you could implement to enumerate each of your completed forms, pull out the relavant data and create list items of that data. I would think there is a way you could do this using the SharePoint object model but this is not my area of expertise. I would suggest you pose this scenario to one of the SharePoint groups.

Scott

# December 10, 2008 9:55 AM

jchavezb said:

Hi Scott

sorry for my english ... but i'm learning :0)

well the example is running now but i need to made this with a choise option, it's is possible? or with data type date? because i'm try and i can get it...

thanks a lot for any orientation ...

Best Regard.

Javier

# December 23, 2008 1:49 PM

infopath said:

Hi Javier,

I am able to use both a "Choice" and "Date" field in my list. Here is how I tested with a new list:

- Created a new list named: ChoiceAndDateTest

- Added 3 new columns to this list:

    - txtName (Single line of text)

    - txtChoice (Choice data type and set the default options to:

         A

         B

         C

    - txtDate (Date and Time)

- Modified my Add List Item Template XML file to the following:

<Batch OnError="Continue">

   <Method ID="1" Cmd="New">

       <Field Name='Title'></Field>

       <Field Name="txtName"></Field>

       <Field Name="txtChoice"></Field>

       <Field Name="txtDate"></Field>

   </Method>

</Batch>

- Updated my "ListName" node in my data source to use the GUID for this new list

- Previewed the form and entered the following data:

    - Title: Test1

    - txtName: Scott

    - txtChoice: A

    - txtDate: 2009-01-05

- Submitted the data and it was correctly added to the list.

Can you try these steps and let me know the results?

Scott

# January 5, 2009 11:21 AM

jchavezb said:

Hi Scott

this work perfect !!! :0)

thanks a lot!! for test was fine...  

Well now i've problem when made my real development because i'm trying to do a form with 12 question (choises ) and 12 observation ... and can´t get it ..!! they don't show any error but my sharepoint list will don't  updated!!!

is possible to catch an error in the comunication between my application and sharepoint ???

May at this point

 <Batch OnError="Continue"> --> I don't want to continue, i need to know the error !! is this possible???

Thanks a lot for your help...

Javier

# January 6, 2009 5:55 AM

jchavezb said:

Scott

I think the big problem is the name in the field of the list (in sharepoint) because i try with two kind of names :

P.e :

- P1 --> don't work and don't show any error, but my list is not updated...

- a --> Work!

:s is very odd but if i change just the name's all work perfect ...mayby by the way is working webservice ???

Best Regard

Javier.

# January 6, 2009 7:34 AM

infopath said:

Hi Javier,

I am certainly glad to hear you were able to get it working; however, I agree - it seems odd that a field name of "P1" does not work. I am assuming that your XML file has the field specified as "P1" and not "p1" - correct? Also - one thing you may want to do is put the field back in SharePoint as P1, recreate the connection from within InfoPath, save out the files from the XSN (File -> Save As Source Files), open manifest.xsf with Notepad, find that SharePoint connection and make sure that field is indeed coming through as "P1". I have seen one case where a customer specified a field name for their column and for some reason the actual name in SharePoint was something different.

Scott

# January 6, 2009 8:33 AM

jchavezb said:

Hi Scott

I am assuming that your XML file has the field specified as "P1" and not "p1" - correct? --> Yes ! i know that XML is Case Sensitive... so i'm using the same name for both!!...

I have seen one case where a customer specified a field name for their column and for some reason the actual name in SharePoint was something different. --> Finally i'm delete both files (List and Form) and try again and OPS! don't show any error but still don't update my list... so i went to the path of the manifest and effectively the name in the sharepoint list is diferent ....

Why this happen ? i think is a bug of sharepoint...

So now i'm trying again deleting both files... but is some tired to do .. because for made a simple form spend so much time.. because if I make a mistake i've to do everything again :0(

Maybe this kind of feature is better not be implemented between sharepoint and Infopath ...

Well i will comment my hard way to get this ....

Thank's a lot again ...

Javier

Ps : I'm thinking in traslate this article to spanish and Portuges, when will be done i tell you...

Best Regard...

# January 6, 2009 9:01 AM

infopath said:

Hi Javier,

I am not a SharePoint expert so I am not sure why the actual name is sometimes different. You may want to post that question to a SharePoint blog and see if you get any insight. However, in the future, once you create your SharePoint list you simply need to insure the XML file contains the same names exactly as they appear in the manifest so a "quick" step is just extract the files from the XSN, open the manifest and verify the names. Then simply make sure your XML file matches what is in the manifest.

Scott

# January 6, 2009 9:10 AM

jchavezb said:

scott

hi look :

<xsf:field sharepointName="b" infopathName="b"></xsf:field>

<xsf:field sharepointName="bo" infopathName="bo"></xsf:field>

<xsf:field sharepointName="_x0063_" infopathName="c"></xsf:field>

i don't know why the name of this field "_x0063_" if in the list is declared like "c" ...

Best Regard...

Javier.

# January 6, 2009 9:22 AM

jchavezb said:

Oki doki scott i will post to a sharepoint blogger  this issue ...  thank again for your usefull help...

Javier

# January 6, 2009 9:25 AM

jchavezb said:

ok scott finally i get the problem was the manifest because this don't update when i change the list on sharepoint for this reason, for example when change a name field on sharepoint the name in the manifest still have keeping  the previous name.

So for example :

if i created a list with "MyList" with a field name P1 and after then i change the name to "Foo" when i try to execute again my form this don't show any error but "MyList" is not Updated...

should not change the manifest if the list be amended?

the manifest keep on cache???

Well my counsil for another peopple that have the same problem is "All the time verify the manifest name's, and if you change a field on the sharepoint list" you should delete the references until both name be the same...

I don't know if you understand but the key for this work is just this...

Thanks a lot i hope this help to someone...

Javier.

# January 6, 2009 11:11 AM

infopath said:

Hi Javier,

After you change a field name in your SharePoint list are you updating the connection in InfoPath? If not, this would be the expected behavior. If you make a modification to the list schema (i.e. add/delete a field, change a name, etc.) you then need to complete these steps in InfoPath:

- From the Tools menu choose Data Connections

- Select your list data connection and click Modify

- Complete the wizard all the way through and now any change you made should be reflected in InfoPath

Scott

# January 6, 2009 1:16 PM

jchavezb said:

Hi Scott

i not make the update just delete the conection to the list and then created a new conection follow the wizard , but still this doesn't work...

At this moment i'm fix this just looking with so much patience all the name's and is working now!! :0)

But for get this all the time was create my list on charepoint - create the conection - see the manifest - when the name's on both sides , when the name were the same - all run perfect... in fact now is working without problem...

for me the problem is with sharepoint or maybe if InfoPath keep a copy on cache ... for example on this case :

<xsf:field sharepointName="_x0063_" infopathName="c"></xsf:field>

On my local XML the name were "c" .

in the list also "c" but how you see on manifest has "_x0063_" , i try deleting the list (don't work, the behavior was the same).

finally created other list and then work... i know is odd but is the only way that get this run ...

Best Regard.

Javier.

# January 7, 2009 5:55 AM

brynnie5209 said:

Hi Scott,

First of all, I've read through all the postings in this blog and you really know your stuff!  I've created a form that submits directly to a SharePoint list, which is great-- solves a problem I've been working on for weeks!

Now I'm trying to modify my form so that it auto-populates the fields from another view within the same form... basically, I've got one view in which users input a bunch of data (which will submit to SharePoint using the regular method), but I've created a second view with your solution, and would like to update columns in a separate SharePoint list based on input the users entered in the first one-- without making them have to switch views or input data a second time.

I thought that after creating the second view with the repeating tables, as per your instructions above, that I could set the default value to equal data from other fields in my first view-- obviously, it doesn't seem possible to do this.  

Any idea how to set a default value for the fields your tutorial has helped me create?  My Add List Item Template looks like the following:

<?xml version="1.0" encoding="UTF-8"?>

<Batch OnError="Continue">

   <Method ID="1" Cmd="New">

       <Field Name='Title'></Field>

       <Field Name="Group"></Field>

       <Field Name="MTSTeam"></Field>

       <Field Name="ProjectManager"></Field>

       <Field Name="PercentOfOverallWork"></Field>

<Field Name="PriorityOfWork"></Field>

   </Method>

</Batch>

But I'd really love to be able to autopopulate those fields with data already entered into the form (OR, figure out how to get the other fields in the first view to populate columns in my SharePoint list without the need for a repeating table, etc.).

Any ideas?  Is this possible?  Or am I out of luck?

Thanks again-- this post has been fabulous!

Brynnie5209

# January 7, 2009 8:15 PM

jchavezb said:

hi Brynnie5209

i'm made some like you but not with autocompletedata, i'm make an WorkFlow that after send the form to the list the list display the data input and data from another list (with a workflow in Sharepoint Designer that can update a List when new item is added).... now if you want to get data from a list this perhaps can help you [1]...

I hope this help you ....

Best Regard

Javier.

[1]: http://cs.vbcity.com/blogs/skullcrusher/archive/2008/12/16/get-list-of-site-users-in-infopath-form.aspx

# January 9, 2009 6:23 AM

jchavezb said:

Hi Scott

Me again i need some more orientation .. i'm trying to publish my form and i need enable the feature "Open in Browser" but i can't get it because in all forum's say that i've to remove my C# code....

This for me don't make sense ... do you know if exist a way to publish with C# code and enable the compatibility to open in a Browser ???

Is this possible??? or just am forced to take the client installed InfoPath???

Thanks a lot for any orientation... i will try ...

Bye Best Regard ..

Javier

# January 9, 2009 7:30 AM

infopath said:

Brynnie5209:

Using the method described in this blog post, you cannot auto-populate those fields. There is another way to do this (without code) but it is an "InfoPath Client Only" option (in other words, it will not work in browser forms) and would require somewhat of a re-design of your XSN. If you would like to pursue this, let me know and I will provide you with the steps.

Javier: Yes - you can publish an XSN with code for browser use - you just have different steps to follow...take a look at this information:

http://msdn.microsoft.com/en-us/library/bb267337.aspx

Also - in the future, please keep all comments and questions specific to the blog topic.

Thanks!

# January 9, 2009 8:34 AM

brynnie5209 said:

Scott,

That would be amazing, if you were willing to provide the steps-- I tried to re-work one of the code solutions you provided for auropravin (who wanted to add a date picker, rich text field, etc.) by entering blank text fields, setting the default, and then tweaking the code you provided to him-- made a total muck of it, of course, as I'm more of a "no code solution" kind of girl.  

Please let me know if there is other information I would need to provide for you; the infopath form I'm using isn't browser-enabled (I was willing to decrease functionality and make it browser form to use your original solution, so I'm thrilled if there's a way to solve for what I'm trying to do without changing a lot of the rest of my form; even MORE thrilled if I don't have to use code).

Javier, thanks for the suggestion-- the link you posted was helpful for another project I'm working on!  

And thanks again Scott for your quick response and willingness to teach me something!  

v/r,

Brynnie5209

# January 9, 2009 9:32 AM

infopath said:

Hi Brynnie5209,

Here are the new steps - and again these will only work using the InfoPath client. (NOTE: I would suggest you first create a new sample XSN to make sure this works and then implement this in your actual XSN.)

This update will still follow the same basic steps outlined in this blog post except for step #7.

- Complete steps #1 - #6 in the original post

- For step #7, implement the following:

    o Right-click on the root “myFields” and choose Add

         * For Name, enter: gpContacts

         * For Type, select: Group

         * Click OK

    o Right-click on “gpContacts” and choose Add

         * For Name, enter: _Title and click OK

         * Repeat the above line adding: _FirstName, _LastName, _Email and _Phone

    o Drag “gpContacts” to your View as: Section with Controls

- From the Tools menu choose Submit options

- Enable the option “Allow users to submit this form”

- Enable the option “Perform custom action using Rules” and click the Rules button

- Click the Add button

- Click the Add Action button

- From the Action dropdown box choose: Set a field’s value

- Click the Select XPath button next to Field

    o From the Data Source dropdown box choose: Add List Item Template

    o Drill down, select the “Field” node and click OK

    o Click the “fx” button next to the Value field

         * Click Insert Field or Group

         * Select the Main data source

         * Drill down through gpContacts, select: _Title and click OK

         * Click OK until you are back to your form template (NOTE: This was just a “sample” rule to help complete the next steps)

- Save the changes to your XSN

- Create a new folder on your computer called: SourceFiles

- From the File menu in InfoPath choose: Save As Source Files

    o Select the SourceFiles folder created above and click OK

- Close completely out of InfoPath

- Navigate to the SourceFiles folder, right-click on manifest.xsf, select “Open with…” and open this with Notepad

- Locate the following node in the file: <xsf:ruleSets>

- Directly under this node, you will see the “sample” Rule that we created above as follows:

<xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;Add List Item Template&quot;)/Batch/Method/Field" expression="my:gpContacts/my:_Title"></xsf:assignmentAction>

- Copy this entire line, scroll to the end of this line, hit Enter and paste this again

- Repeat the above step three more times so you have a total of five lines that have the same information (the number of lines you have here correspond to the number of fields in your Add List Item Template.xml file)

- Add an “index” to each “Field” node, like this:

<xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;Add List Item Template&quot;)/Batch/Method/Field[1]" expression="my:gpContacts/my:_Title"></xsf:assignmentAction>

When you are done you the index number should be incremented for each "field" (i.e. [1], [2], etc.)

- Modify the “expression” portion of each assignment to point to the appropriate node in your “man” data source:

For each line, change: my:gpContacts/my:_Title to point to the correct node that we added (i.e. _Title, _FirstName, etc.)

NOTE: It is very important that your “expression” nodes are in the same order as what you have in your Add List Item Template.xml file. In this sample, “Field[1]” is Title, “Field[2]” is FirstName, etc. Also – like all XML, capitalization must also match what you have in your data source.

- Save these changes and close Notepad

- Right-click on manifest.xsf but this time choose Design (this will open in InfoPath)

- From the File menu choose Save As and save this as your original XSN

- Now we need to complete the “submit” option

    o From the Tools menu choose Submit Options

    o Click Rules

    o Select our Rule and click Modify – you should now see each of the lines that we added in the manifest and each will be "indexed".

    o Select the last entry in the Rule and click Add Action

    o From the Action dropdown box choose: Submit using a data connection

    o Select your Web Service Submit connection and click OK

    o Click Add Action

    o From the Action dropdown box choose: Query using a data connection

    o Select the “MyContacts” data connection and click OK

- Click OK until you are back to your form template

- Click Preview

- Fill in the new fields and click Submit on the Toolbar – the data should be populated in your list!

A couple of points:

- With this new design, you now have the ability to use other controls, such as a Dropdown list box or a Date Picker control. In this manner you can take advantage of populating your dropdown with data from a secondary data source to make data entry easier

- If you create a “DateTime” column in your SharePoint list, do *not* create that node in your main data source as “DateTime” – it must still be created as “Text (string)”

I hope this process works for you!

Scott

# January 9, 2009 10:10 AM

Jamz said:

Hi Scott,

Thanks for this great tutorial! It worked a treat for me. My problem is styling.

Im currently doing a company project for user requests, and hopefully my form will get passed around all the managers in the company. Now if i gave them the above, i dont think they would be very happy with just a list of forms which didnt really mean much to them.

What I'm after at the moment is a InfoPath form which just submits to the list (wont be displaying any information from the list in the form) which is basically what you have above. But i would like to design my own form, and not have the form output from the list.

Is there any way to do this?

Cheers

Jamz

# January 9, 2009 10:23 AM

infopath said:

Hi Jamz,

I am not sure I completely follow what you are asking; however, the only reason I include the list items in this sample is just so you can see it was added. There is no need to have the existing items display on the XSN. In regard to form design, using this blog limits what you can do; however, take a look at my prior response to Brynnie5209 - this is a different way to design the XSN so you have more control over formatting; however, this will *not* work in the browser unless use code, which means you really don't need anything from this blog post. :)

Scott

# January 9, 2009 10:32 AM

jchavezb said:

Hi Scott

Is just for thank you for the help i'm finish my prototipe and everythinks is running Ok !

So see you the next time....

Best Regard.

Javier.

# January 12, 2009 6:14 AM

infopath said:

Hi Javier,

I am glad to hear everything is working for you!

Take care,

Scott

# January 12, 2009 7:59 AM

brynnie5209 said:

Scott,

Just had to write back to THANK YOU for the wonderful help-- your solution worked like a charm, and I'm now able to do so much more with the data my team submits.  This solves a problem we've been trying to work out for months, and I can't tell you how refreshing it's been to have someone help you solve a problem while simultaneously teaching you something along the way.  Thank you again; I really appreciate it, and look forward to reading more of your posts in the future!

v/r,

Brynnie5209

# January 19, 2009 9:56 AM

infopath said:

Hi Brynnie5209,

That is great to hear - thank you! :)

Scott

# January 19, 2009 10:12 AM

jchavezb said:

Hi Scott:

I'm here again so i've another problem :0( , once i test my aplication on my computer connect to the server all is ok ... but i've a Virtual machine like server and there i've one user by default and when this user try to send the form , appears this message:

at Microsoft.Office.InfoPath.MsxmlNavigator.IsValidNode(MsxmlNode test)

  at Microsoft.Office.InfoPath.MsxmlNavigator.MoveToFirstChild()

  at MS.Internal.Xml.XPath.XPathChildIterator.MoveNext()

  at MS.Internal.Xml.XPath.ChildrenQuery.Advance()

  at MS.Internal.Xml.XPath.ChildrenQuery.Advance()

  at MS.Internal.Xml.XPath.ChildrenQuery.Advance()

  at MS.Internal.Xml.XPath.XPathSelectionIterator.MoveNext()

  at System.Xml.XPath.XPathNavigator.SelectSingleNode(XPathExpression expression)

  at System.Xml.XPath.XPathNavigator.SelectSingleNode(String xpath, IXmlNamespaceResolver resolver)

  at SataFinal.FormCode.Btn_Submit_Clicked(Object sender, ClickedEventArgs e)

  at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)

  at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

But if send from my pc all run right ... you know can happens??? why this behavior??? may be i've to do some more configuration ????

Thanks a lot for any orientation...

Javier.

# January 19, 2009 11:36 AM

infopath said:

Hi Javier,

There is probably more to this error message but it appears it is failing when submitting the data. You may want to check the following items:

- Does that user have permission to add items to the list?

- Is the XSN set to Full Trust? If so - did you sign it with a certificate?

- You could also run the Fiddler (or Netmon) tool to trace what is occurring to see if this helps isolate the problem.

If you need more assitance troubleshooting this, you may want to open a support case to dig into this further.

Scott

# January 19, 2009 1:48 PM

jhillppc said:

Hi, Scott - the meeting minutes form is working beautifully for us, but of course now the CIO wants to spiff it up by automatically retrieving agenda items that are posted to another list in the same site.  I configured the data connection to retrieve the fields that we need; however, there is a Notes column (Multiple lines of text) in the list that does not appear in the list of available items to select when creating the data connection.  The other columns are "selectable" and appear just fine in the form.

Is there any restriction on this type of column? Thanks for any suggestions.

Jan

# January 30, 2009 3:30 PM

infopath said:

Hi jhillppc,

Correct - some data types are not available via the list connection like this; however, you should be able to get all the columns using the method described in this blog post:

Populating form data from SharePoint List Views

http://blogs.msdn.com/infopath/archive/2007/01/15/populating-form-data-from-sharepoint-list-views.aspx

Scott

# January 30, 2009 4:17 PM

jhillppc said:

Hi, Scott - regarding the VS code that submits to the Sharepoint list--there are two fields that the requestor initially completes and then submits the form.  Our group opens the form and completes other fields to be submitted to the list.  That works fine, but I'm trying to determine how to add the two fields that the user submitting the form completed to the same list--is it possible to add to the submit code or do we need another data connection?  Being programming-challenged, I don't know the syntax to test.

Here's a line adding one of the fields from the secondary data connection:

xnAddServer.SelectSingleNode("/Batch/Method/Field[@Name = 'Host']", ns).SetValue(xnMain.SelectSingleNode("/my:serverRequest/my:svrInfo/my:_VMHostIP", ns).Value);

I want to add "Requestor" and "Project" from the Main data connection.

Thanks and have a great weekend.

Jan

# February 20, 2009 2:40 PM

infopath said:

Hi Jan,

You should not need to add a new connection; however, to "update" an existing list item you will need to be sure you have that items "ID" value. So be sure this field is in your data connection. Then you should be able to add those two new fields to the data connection and implement the same basic code.

Have you tried this approach yet?

Scott

# February 23, 2009 8:23 AM

jhillppc said:

Hi, Scott - added "ID" to the addserver.xml; and to the secondary data connection, so now ID, Project and Requestor appear in the secondary data connection.  The two additional lines have been added to the code.   Form published and uploaded on the Sharepoint applications, Manage Form Templates site.  A new form loads and can be properly submitted.  

BUT, when trying to update the form, then submit to the list, I get "An entry has been added to the Windows event log...Log ID: 5337."  Haven't found much on this error, but that's where I'm at, down here in the deep end again.

Thanks for the info.

Jan

# February 23, 2009 3:47 PM

infopath said:

Hi Jan,

What you will probably need to do at this point is step through your code to make sure everything is working as you expect, variables are set to the correct values, etc.

If you need more assistance with this it may be better to open a support case so someone can work with you 1:1 to help debug the problem.

Scott

# February 23, 2009 4:01 PM

lokeshd said:

hi Scott,

Thanks for the article.

I followed the steps described in this article. When I click submit I get the message saying "This form was submitted succesfully". But there is no new item in my contacts list.

I found

Soap error: Unspecified HTTP error..

Event Xml:

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">

 <System>

   <Provider Name="MSSOAP" />

   <EventID Qualifiers="49152">16</EventID>

   <Level>2</Level>

   <Task>4</Task>

   <Keywords>0x80000000000000</Keywords>

   <TimeCreated SystemTime="2009-03-23T13:20:30.000Z" />

   <EventRecordID>868</EventRecordID>

   <Channel>Application</Channel>

   <Computer>BDMWS-02.sunplusdata.com</Computer>

   <Security />

 </System>

 <EventData>

   <Data>Unspecified HTTP error.</Data>

 </EventData>

</Event>

please specify the solution for this error :

# March 23, 2009 1:34 PM

infopath said:

Hi lokeshd,

There are a number of comments in this blog on the exact behavior you are seeing. I would encourage you to read through all of these as you will get insight on what to check but here are a few of the more common reasons you will see that behavior:

- The web service URL for the "lists.asmx" web service you added is not at the same "site level" as where your list exists. For instance, if your "Contacts" list is at the root, then your web service URL connection would be like: http://server/_vti_bin/lists.asmx however, if your Contacts list is on, say, a subsite then the URL would be like this: http://server/site/_vti_bin/lists.asmx. In short - make sure you are referencing the lists.asmx web service at the correct site level.

- Make sure your XML file contains only those column names you added - if there is a column in the XML file that does not exist it will cause a problem.

- Make sure the names you specified in the XML file are spelled correctly (including capitalization)

- With the columns that you added in SharePoint - did you include spaces in the name? If so - it's not as simple as just adding spaces in the name in your XML file (to see how the names come into InfoPath, create a new XSN with a receive connection to your list. Then from the File menu choose Save As Source Files and look in the manifest.xsf file.)

** I would suggest you do the last bullet anyway just to be sure the names coming from SharePoint are exactly what you think they are and have specified in your XML file.  Once you extract the source files, open manifest.xsf with Notepad and then look for the "xsf:sharepointListAdapter" node - below this will be the actual field names as they come from SharePoint.

# March 24, 2009 10:43 AM

bawcior said:

Awesome! I had a lot of problems getting this to work and it turns out the column names were not what I was thinking they were. One way to check your column names as they appear in web services is to click on column name in the list and then look at the last field, for example:

http://somesite/_layouts/FldEdit.aspx?List={58E78B34-EE26-4E5F-BC7D-A4F8189775F8}&Field=E_x002d_mail_x0020_Address

In this case my column name was E-mail Address which resulted in E_x002d_mail_x0020_Address

I haven't read all the comments yet. What about Data validation, how can that be done (the easier the better)? Let's say I want to have e-mail field and confirm email fields and check if they are both equal (using Infopath rules to do so would be preferred) And also what about better formatting for the fields and making the form look good?

In any case, this is great. I used this to get aroung anonymous submission problem (since anonymous users can add items to the list, but not libraries)

# March 27, 2009 7:50 PM

infopath said:

Hi bawcior,

I am glad to hear you were able to get the process to work! :)

In regard to your other questions, we need to keep the blog posts specific to their topic so I am not going to go into a lot of detail.

- Validate e-mails: You will want to look at using Data Validation on each e-mail field and possibly look at using the "translate" function. If you don't incorporate the "translate" function these e-mails, for example, will not match:

abc@hotmail.com

abc@hotmaiL.com

- Formatting: That question is obviously very broad and could be quite subjective. :)  I would encourage you to poke around the Microsoft site (after searching for InfoPath) and you should find some good pointers.

Scott

# March 30, 2009 2:32 PM

ElenaS said:

Hello Scott!

Thank you so much for the solution.

I have a related question for you, however. In the revolving table from the Batch data source, how can I make the entries multiple choice?I know I can change the cell to a Drop Down list, but how do I get the drop down values to be individualized for each cell on the Preview side?

I thought I could instead build other cells in the forms data source and make those multiple choice and have the information in the Batch revolving table feed from those cells, but I still do not know how to separate each individual entry. Does my question makes sense?

Thanks!

Elena

# April 7, 2009 11:57 AM

infopath said:

Hi Elena,

This is how I am interpreting your question: when you follow the steps documented in this post, all of the fields to be completed show as basic text boxes. What you would like to do is have one or more of those be dropdown boxes - is this correct?

If so, then the way to do this is documented in my response to a user on 1/9/2009 in this post. However, it is important to know that this option will *only* work for forms you will be using in the InfoPath client. If your XSN is designed for both the client and the browser, then you would still need to make the basic design as I documented on 1/9/2009 but you would need to use managed code to populate the XML file used for the list update. (In other comments in this blog, I have provided code to perform the updates.)

Scott

# April 7, 2009 3:43 PM

bawcior said:

I want to set some of the fields that are being submitted to SharePoint  to some value (not user typed). How do I do this either in InfoPath or C#? Thanks

Pawel

# April 7, 2009 4:26 PM

infopath said:

Hi Pawel,

Take a look at my response on November 18, 2008 - there is sample code there and part of that is setting values in the XML file.

Scott

# April 8, 2009 9:07 AM

jborean said:

My goal is to have an InfoPath form submit fully to SP list... not just set up column data.

If it is submitting to a SP list... where does it get initiated from? Could we use a document library to initiate the form and have it submit to a list and not to the library at all (effectivelly just using the document library to pull up the template)?

I plan on using qRules to submit attachments to a SP list to reduce the load time of my InfoPath form. It would be my dream if I could call up an InfoPath form and then submit the form and attachments (seperately) to a single item on a list.

v/r,

Jason Borean

# April 24, 2009 3:05 AM

infopath said:

Hi Jason,

I am not sure I fully understand what you are asking. From an InfoPath perspective, out of the box you can submit to a SharePoint "library", which means the entire form gets sent to the library as a document. You can submit the form "data" to a SharePoint "list" but this is not available out of the box (hence this blog) but only submits the data in the form (and in the columns you specify) to the list.

So in this case, your question of "where does it get initiated from" - that would be from InfoPath. In addition, to include submitting an attachment - that would be a separate web service call to the list item because this needs the list item ID, which we would not know until the data has been submitted to the list and the item created.

In regard to your question of submitting to the list and not to the library - sure...this can certainly be done. If you follow the steps in this blog, you would only have one submit connection, which would be to the list. So although you may be "publishing" your InfoPath Form Template (XSN file) to a SharePoint library, you do not "have" to submit to that library. This may simply be the point to which a user launches the form, fills in the data and then clicks Submit...which may only be to your list.

I hope this helps!

Scott

# April 24, 2009 8:16 AM

amod_goyal said:

Hello Scott and all the developers,

Great post. Used InfoPath 2003 to populate data to SharePoint 2007 list. Can you help me with your ideas or direct me to a blog/URL for the following.

Two major areas where I am getting freezed up:

1. Instead of using CAML template, if I create  form design in Infopath directly and then I want to submit the data to list? Since my form is pretty big with different type of controls including combo, text box, tease area, date, file attachment and they get displayed according to combo box selections. Please suggest a way for this or other ideas around this.

2. Since I have a file attachment control, that needs to be attached to the item in the list, you mentioned in your previous reply that "it needs to be a separate web service call to the list item because this needs the list item ID, which we would not know until the data has been submitted to the list and the item created". Can you please me direct me towards that solution.

Thanks in adavnce!

Ami

# May 13, 2009 9:19 AM

infopath said:

Hi Ami,

I am not sure I follow what you are asking in question #1. Are you asking how you could submit your data to a list without using the CAML XML template? If so, then the only way to do this would be to use custom code - in the code you would basically be creating the CAML expression to send the data to the list. If this is what you are asking, take a look back through the comments on this blog as I have provided sample C# code on how to to this basic process.

In regard to question #2 about adding an attachment - you would need to use custom code to extract the contents of the attachment (see http://support.microsoft.com/default.aspx?scid=kb;EN-US;892730) and then make a call to the AttAttachment method of the "lists" web service to upload the extracted file contents to the list (http://msdn.microsoft.com/en-us/library/lists.lists.addattachment.aspx).

Scott

# May 15, 2009 8:53 AM

zhangweisjz said:

How to retrieve data from SharePoint List using InfoPath 2003

Hi Scott, I have been troubled in this question for a long time. My request is this:

Say there is a SharePoint website on my domain, and I have admin rights to the website but have no write access to the SharePoint Server. I want to design a infopath 2003 form, with 2 or 3 textboxes, one search button and one repeating table. When I type in the textboxes the search words, and then clicking button, the repeating table will display the values retrieved from SharePoint List.

Please do me a favor to give me a detailed guide! Thank you very much!!

PS: I have the environment to write managed code(VS2003 and Infopath SDK) , but there is a small problem: I can not using Microsoft.SharePoint.dll, what's the reason for this? Is this because I don't have Windows SharePoint Service 3.0 installed on my OS windows XP professional?

Thanks again!!

# May 18, 2009 3:24 AM

infopath said:

Hi zhangweisjz,

You will need to use code to do this but it is relatively simple. I would suggest using the method described in this blog post to create the data connection to your list:

http://blogs.msdn.com/infopath/archive/2007/01/15/populating-form-data-from-sharepoint-list-views.aspx

The reason is we can easily append "filter fields" and "filter values" to the URL which will be used to only return back the records that match your search criteria.

The following is how I setup my sample:

1) SharePoint List:

    - Column Name: Alias (single line of text)

    - Column Name: WorkedFor (single line of text)

2) I have two records in my list:

    - Alias: sheim, WorkedFor: jasperh

    - Alias: joelall, WorkedFor: tabb

3) Here is the main data source in my XSN:

myFields

    txtAlias

    txtWorkedFor

4) Added a data connection (called: GetListItems) to my list using the above referenced blog (NOTE: I just did the first few steps and make sure you review the "Caveats" comments. I did not do anything in the "Some tricks" area...these I do in code. <g>)

** Make sure you uncheck the option to retrieve the data when the form loads - we don't need to do this.

5) Added my two fields a button to the view and the repeating "z:row" (from the secondary data connection) to my View as a Repeating Table

6) I have the following code on my button click event:

//Create IXMLDOMNode objects for my search fields

IXMLDOMNode nodeAlias = thisXDocument.DOM.selectSingleNode("/my:myFields/my:txtAlias");

IXMLDOMNode nodeWorkedFor = thisXDocument.DOM.selectSingleNode("/my:myFields/my:txtWorkedFor");

//Create an int variable to increment the "filter field" and "filter value" number

int i = 1;

//Create an XMLFileAdapterObject for my XML (SharePoint list) data connection

XMLFileAdapterObject dList = (XMLFileAdapterObject)thisXDocument.DataAdapters["GetListItems"];

//If the "txtAlias" field is not empty then append this to the search value to the URL

//and increment the field counter

if (nodeAlias.text != string.Empty)

{

dList.FileURL += "&FilterField" + i + "=Alias&FilterValue" + i + "=" + nodeAlias.text;

i += 1;

}

//If the "txtWorkedFor" field is not empty then append this to the search value to the URL

//and increment the field counter

if (nodeWorkedFor.text != string.Empty)

{

dList.FileURL += "&FilterField" + i + "=WorkedFor&FilterValue" + i + "=" + nodeWorkedFor.text;

i += 1;

}

//Now, query the connection

dList.Query();

What this code will do is see if any of your "search" fields (txtAlias and txtWorkedFor) contain values - if they do, the code appends the "FilterField" and "FilterValue" pieces to the URL (along with the appropriate counter value) and then executes the connection.

I hope this helps!

Scott

# May 18, 2009 8:50 AM

zhangweisjz said:

Great Great Thanks!

Hi Scott,

I can say nothing but thanks for your great great help! I followed your guidance and it really works! Althrough I am in distant China, I was touched by your kindness.

But I a little greedy that I have two other relevant questions, please help:

1, How can I make foggy search (or say as T-SQL "like" function, in your example -- Alias: sheim, WorkedFor: jasperh, when you input "she" in the form, the result "Alias: sheim, WorkedFor: jasperh" can also be displayed). How can I make this feature?

2, How can I update the value of result? Let me take "Alias: sheim, WorkedFor: jasperh" for example, if I change sheim to zhangweisjz, and click a button, the valued is submitted by the SharePoint List. (I don't mind the way of writing code to solve this problem)

3, When creating a form in SharePoint form library, user will have to save the form and type in a certain name. Could we have a function that form can generate a random string as its name when saving?

Thank you very much!

PS: I made a small modification of your codes, so that we can search more than once:

string tempURL=dList.FileURL;

if(nodeAlias.text!=string.Empty)

{

dList.FileURL+="&FilterField"+i+"=Alias&FilterValue"+i+"="+nodeAlias.text;

i+=1;

}

......

dList.Query();

dList.FileURL=tempURL;

I dare not show my poor programming skills to a master, but to make it simple to use if someone also needs to make this kind of function.

# May 19, 2009 10:21 AM

infopath said:

Hi zhangweisjz,

I am glad you were able to get the sample working!

In regard to your other questions:

#1: I am not a SharePoint expert but I don't know if there is a way to implement "fuzzy" searching as I don't believe SharePoint suppports (by default) wildcard searching. This may be better posed to a SharePoint blog.

#2: You can use the methods described here throughout the comments to update the list. You can either use the XML Resource file method or simply build the CAML query in code and perform the update. Now - you can place a button control in a new column in your repeating table and this will allow you to update just the values in that row or you could use a button outside of your repeating table and use code to loop through all the rows and update the values.

#3: Instead of using the built-in Save, create a "Submit" data connection. This way you can use formulas and/or fields from your form to create the file name.

Scott

# May 19, 2009 4:47 PM

brynnie5209 said:

Scott,

Once again I want to thank you for the help you gave me back in January to enable my InfoPath form to auto-populate fields (and therefore users to input data from different types of fields [date boxes, drop-downs, etc.]) before submitting to a SharePoint list.  The solution you helped me with has been so popular, in fact, that I’ve been asked to use the method again to create a different type of form for my group, which leads me to another opportunity to pick your brain, posted below:

I’ve been asked to create an InfoPath / SharePoint solution which will enable users in our group to submit “tokens” to other employees in our organization as a thank-you/atta-boy.  Each FTE starts the year with 100 tokens to give out to others, and at the end of one year awards are given out to employees who have achieved certain levels of received tokens.  My InfoPath form enables users to nominate someone for a token, and the data is then (successfully, thanks to you) submitted to a SharePoint list which tracks all of the nominations.  The other part of your solution is applied when a user opens up a new form—the InfoPath form pulls the SharePoint list data into the table that’s created in my form (step 5 from your original instructions), and I’ve used sum and counting functions within this table to track how many tokens the user has submitted, received, and (with a little bit of math) has remaining to give out.  

This works like a charm in my testing environment (i.e. submitting to a blank SP library with new data), but I’m creating this solution as a 2nd version to an old method, which means I will be working off a SP list that has 7000 rows once I migrate all the archived token data into my created SP list.  This is (obviously) causing me a number of problems, including:

1. Item limits in the SharePoint list—I’ve configured the list view to show all items, which works fine in SP but still doesn’t manage to pull all of my rows to my InfoPath form to enable the token-counter function I’ve created.

2. Even if I cleaned up the archive so that the list started with less rows to track and did some manual work to keep the SP library from getting too big, I’m noticing that anything over 500 rows in my SP list causes my InfoPath form to open VERY slowly.

My question, after all that build-up, is this:

I know you mention in your original posting that you can configure the InfoPath form to NOT pull list data back into your form, but I need that data in order to perform the token-counting functions I’ve set up.  Is there any way to pull the SP List data in such a way that, rather than individual rows, the data I pulled from the SP list I’m sending to could either be consolidated in some way so that my form doesn’t get too unwieldy, OR is there a way to configure my form to only pull data from specific COLUMNS in the list?  I’m hoping that one of these options may enable the functionality I’m trying to achieve without causing the form to hang while opening and still enable the token-countdown function I need to complete my solution.

I’m hoping this is still considered on-topic for your blog posting; I know I’m touching on a couple of other areas (SP Item Limits, etc.), but I’ve tried a number of other ways to achieve the same outcome with no success.  Any thoughts on whether or not I can enable token-counting using the method you’ve outlined in this blog would be greatly appreciated.  Thanks again!  

Sincerely,

Brynnie5209

# June 1, 2009 3:04 PM

infopath said:

Hi Brynnie5209,

I am glad to hear things are working well!

In regard to your new questions:

1) Showing all items in InfoPath:

    - Navigate to your list

    - Select the "Modify this view" option from the View dropdown (make sure you are showing the default view)

    - Expand the Item Limit option

    - Select the option "Limit the total number of items..." and then set the number to something larger than you think you will need (i.e. 10000)

2) Amount of data returned

    - If you complete the above steps, your form will get even slower <G>

    - As you have seen returning large amounts of data to an InfoPath form will cause it to slow down drastically. I am not going to go into here all the reasons why but you will really need to limit the amount of data you return. So - some things you can look at trying:

- When you created your data connection to the SharePoint list, you can select which columns you need to see - make sure just the ones you absolutely need are checked

- If there is a column where you could provide a "filter" (i.e. only return data for 2009 as an example) then you could use the method described in the following blog post to create a different type of connection where you can provide a filter "field" and a filter "value":

http://blogs.msdn.com/infopath/archive/2007/01/15/populating-form-data-from-sharepoint-list-views.aspx

- If these options do not help then maybe a better option would be to store this data in a database (i.e. Access or SQL Server) where you could create a query (view) in the database that would return just a "summary" of the tokens, something like this:

Scott Heim, 50 tokens remaining

** This assumes that you don't have 7000 rows corresponding to 7000 employees. :)

I hope some of this helps!

Scott

# June 2, 2009 5:32 PM

jhillppc said:

Hi, Scott - hope you're doing well.  Thanks again for your expertise in solving our problems with Infopath and our Meeting Minutes a few months ago.  I've been tasked with setting up another list for submitting help desk requests, and created the list from the Help Desk application template.  Of course some modification of the list was required by adding a few columns, and the editform.aspx and dispform.aspx had to be modified to accomodate the new columns.  The "Comments" field was left as is--columnwise and on the forms--and data can be entered the first time a list item is edited.  If someone needs to go back to the item to add more comments, any previous entry appears in the dispform.aspx, but disappear when the editform.aspx opens.  All other fields remain populated.  I've verified that "@comments" is referenced in the table on both forms, and can view the data using "show data values."  Just another one of those SP gotchas?  Any thoughts other than trying to recreate the Comments field?  Thanks much.

Jan

# June 4, 2009 12:36 PM

infopath said:

Hi Jan,

Glad to hear all is going well! :)

The editform.aspx and dispform.aspx are the built in SharePoint forms used to view and update list items - correct? If so, I don't have enough SharePoint expertise to understand why this occurs. If you can tell me where you downloaded the Help Desk template, I can try it on my side to at least see if I get the same behavior.

Scott

# June 4, 2009 2:04 PM

jhillppc said:

Scott - I found it at http://www.microsoft.com/downloads/details.aspx?FamilyId=CE90D6D7-7B96-47BF-A22F-A7E8C5D40647&displaylang=en

Please don't spin your wheels too much on this...I can try deleting the column and re-adding as a last resort.  Thanks for your quick response!

Jan

# June 4, 2009 3:59 PM

infopath said:

Hey Jan,

Thanks - as this appears to be solely a SharePoint application, I'll let you see what you can find. If deleting and recreating the Comments column does not help, it will probably be worthwhile to touch base with one of the SharePoint blogs. Hopefully they can shed some light on it for you.

Now, if this is something that only appears when using InfoPath, then let me know. :)

Take care,

Scott

# June 4, 2009 4:20 PM

zhangweisjz said:

Hi Scott,

Sorry to bother you again. These days I am working on InfoPath it is fun but I also got a lot of questions.

Question1:

I have a request that can InfoPath avoid user to save a form which has a same value as another one?

For example,

A booking car infopath tool,

If one user has finished his applicaton:

car number: 'ABCD', time: 2009/6/8 8:00:00 to 2009/6/8 12:00:00,

Another user can not save a template if he filled his application form with the same content:

car number: 'ABCD', time: 2009/6/8 8:00:00 to 2009/6/8 12:00:00.

Is this possible?

Question2:

And going further, is it possible to avoid:

If the time frame 8:00:00 to 12:00:00 is booked, the application form with the time frame 8:00:00 to 18:00:00 can also be prevented.

The last question:

When we save a form, we will have to manually input the form's name, is it possible that the system will generate  a number (random or other kinds) as the form name?

Thank you very much.

Sai

# June 7, 2009 11:01 PM

zhangweisjz said:

Our user has another concern about the required *field with empty content still can be sent out to forward to next step.

Is it possible to solve this?

Thank you.

# June 8, 2009 5:35 AM

infopath said:

Hi Sai,

In the future please post questions that are relevane to the blog topic.

1) How to avoid saving a form with the same name?

>> If you are going to use the "save" functionality then the only way to avoid this will be using custom code to see if the form already exists. However, if you use the "submit" feature of InfoPath, you can use fields from your form template, expressions, etc. to generate the form name when it is submitted and when you setup that submit connection, there is an option to either allow or disallow overwriting an existing form.

2) Avoiding a specific time frame?

>> Off the top of my head, this would require custom code to see what is or is not available. However, this may also depend on your form design.

2A) See answer to question #1.

3) Required fields can still be sent out.

>> I am not sure how you are "sending the form out" but if you were to use the submit connection again, you would not be able to "submit" the form until all required fields are completed.

If you need more assistance with any of these questions Sai it may be more prudent to open a support case so we can take a look at your design.

Scott

# June 8, 2009 8:27 AM

zhangweisjz said:

Hi Scott,

Thank you for your reply.

I would like to Share my design to you. Could you please send me a email so that I can get your address?

Mine is zhangweisjz#gmail.com, please replace # with @.

Many thanks.

Sai

# June 8, 2009 10:08 AM

infopath said:

Hi Sai,

Unfortunately I really don't have the ability to do this as I am in support and need to spend the majority of my day assisting customers that have opened support cases.

I provide answers and samples on this blog as I have time but to review a design and suggest solutions or changes to that design is something I don't have the time to do.

I hope you understand.

Scott

# June 8, 2009 10:14 AM

dips23 said:

Hello , Scott !!

Thanks for this helpful article regarding submition to sharepoint list .

i tried this article to submit to list and cheked 4-5 times , but i m not getting data in list after i entre data through infopath form , i get the msessage that tell me that " The FOrm was submitted succefully " but its not inserting data into list , as my form display the data from list , but there is only problem in inserting the infopath form data into list...

i stuck with this problem since many days could you help me please as soon as possible please !!

Thanks & Regards ,

Dipti Chhatrapati

# June 20, 2009 1:45 AM

infopath said:

Hi Dipti,

I know there are a lot of comments to this post but please read through all of these as there were a number of questions about this same behavior and there are numerous reasons why this behavior occurs and I have documented those throughout the comments.

Thanks,

Scott

# June 22, 2009 8:04 AM

dips23 said:

Hello…

Thank you very much for your kind reply!!

But I have followed following steps after reading comments in this blog

1) Proper GUID for list identification.

2) I did connection properly for submit and receive type.

3) I get list web services for appropriate site too.

4) I checked event log to check errors , but didn’t get any.

5) Xml file also contain appropriate fields as columns in list.

is there any testing missing ??? Please tell me so I can get result ASAP.

Thank You,

Dipti Chhatrapati

# June 23, 2009 5:30 AM

infopath said:

Hi Dipti,

Here is what I would suggest you review next:

- Create a new folder on your machine called: SourceFiles

- Open your XSN in Design View

- From the File menu choose Save As Source Files and select the SourceFiles folder you created

- Close InfoPath completely

- Open the SourceFiles folder, right-click on manifest.xsf, choose Open With and select Notepad

- Scroll down in the manifest until you find a node that starts as follows: <xsf:sharepointListAdapter

- Within in this node are all the column names from your SharePoint list, like this:

<xsf:field sharepointName="Title" infopathName="Title"></xsf:field>

- Pay particular attention to the spelling of the "sharepointName" for each column - this is how that field must be spelled in the XML file.

Scott

# June 23, 2009 8:07 AM

dips23 said:

Hello Sir ,

Thanks for your reply !!

i followed all your steps what you suggested , and the field name of CAML file and manifest.xsf file both are exactly same , but i found one mistake in my CAML file

that should be as follow...

<?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="Email"></Field>

       <Field Name="Phone"></Field>

   </Method>

</Batch>

here in "  <Field Name="Title"></Field>" , you mentioned single quote around Title !!!

and i guess jsut coz of this thing people not getting data in list !!!

i am really very thankful to you that ultimetly i resolve this problem wht you suggested to me !!!

Thank You very much again :) !!

Thanks & Regards,

Dipti Chhatrapati

# June 24, 2009 1:59 AM

infopath said:

Hi Dipti,

Hmmm...that is odd as I re-use the same XML file over and over again for testing and the Title field uses the single quote. So I am certainly glad to hear it is working <g> I am not sure why that would be the issue.

But as long as it is working...all is well! :)

Take care Dipti,

Scott

# June 24, 2009 7:51 AM

Steve Hinkle said:

I'm an end-user (content administrator), not a developer, so hopefully my question will make sense to you.  My company is implementing InfoPath 2007 very soon and I am wondering if it can work with an existing SharePoint list?  Specifically, will the survey form I create using InfoPath allow the user to edit and overwrite their response (which is already stored in my existing SharePoint list)?  I'd like to be able to use the existing data and not make the user re-input it into a blank SharePoint list.  Thanks for your help.

Steve

# June 30, 2009 10:07 AM

infopath said:

Hi Steve,

In order for InfoPath to be able to update items that already exist in a SharePoint list, you will need to write code (samples are in these blog comments.) However, since you are asking about a survey you may want to post that question to a SharePoint blog as it may be easier to just use SharePoint features for that. I'm not trying to steer you away from InfoPath but you really would need to know code to update existing items. If, however, all you want to do is "add" the survey responses to an existing list then this post would allow you to do that.

Scott

# June 30, 2009 10:56 AM

maxrase said:

Hi Scott and thank you for this post. Maybe you have already answered to my question but I have a problem.

Your tutorial works fine and I can send datas to my SharePoint list. But I can't change the value of the textboxs used to send the form. Indeed, in the XML file, I can only set static value such as

<Field Name="Title">Test</Field>

Instead of using a static value (in my example : Test), is it possible to set a value of an other textbox used in my main data source.

Thanks.

Maxime

# July 7, 2009 10:55 AM

infopath said:

Hi Maxime,

If you are using the default form design here in this post, then you will need to include the "Title" field on the form so the user can enter the appropriate title. However, if you look further down in the blog comments, I have shown how to re-design the XSN so you can add your own type of fields (i.e. dropdown, date picker, etc.) In this case, you could have another node in the data source, that does not show up on the form unless you want it to, and the value of this node could be an expression based on the other values the user has entered.

It is important to note that unless you switch the design to use code, the "other" method I mentioned above for the design will only work if you are using the form in the InfoPath client - it will not work for browser forms.

Scott

# July 7, 2009 3:58 PM

maxrase said:

I found a good solution thanks to this post. Scott, do you thing that my form will work with InfoPath Form Services despite the custom code ? Is is considered as Managed Code ?

Thanks

Maxime

# July 8, 2009 11:06 AM

infopath said:

Hi Maxime,

Yes - this is managed code and the code I have provided here in this post, will work in browser forms as well. However, once you add managed code to an InfoPath Form Template, it changes the way in which the XSN gets published and used in your MOSS site.

Take a look at this documentation: http://office.microsoft.com/en-us/infopath/HP101000931033.aspx#5 and then this link for the server side steps:

http://msdn.microsoft.com/en-us/library/ms772405.aspx

Scott

# July 8, 2009 11:21 AM

amoghjain said:

Hi infopath..

I was able to learn many things from this blog and did implement the contact list successfully.

now I am trying to do the same thing with a excel file I imported as a custom list. But when I try to submit, i get a confirmation message, and nothing gets added to the list.

I am not sure but this may be related to the title field, which is not their in my custom list. my list has class, characteristic, and description feilds.

this is the exact version of the code i am using and i have double checked my GUID and the site(subsite in my case) i am submitting to.

<?xml version="1.0" encoding="UTF-8"?>

<Batch OnError="Continue">

   <Method ID="1" Cmd="New">

       <Field Name='Title'></Field>

       <Field Name="Class"></Field>

       <Field Name="Characteristic"></Field>

       <Field Name="Description"></Field>

   </Method>

</Batch>

looking for you reply,,

thanks

amogh

# July 9, 2009 2:28 PM

infopath said:

Hi amogh,

Please be sure to review all the comments in this posting - this issue has been raised a number of times and the suggestions to resolve it are always the same.

Now, in regard to your "Title" column being missing, I have not tested this before so I don't know if this is impacting the issue or not. However, even if the Title column exists in the list, it is not "required" to be on of the fields that you include in the XML file to submit to the list. In this case, the Title simply shows as "(no title)" in the list itself.

Scott

# July 10, 2009 8:06 AM

dips23 said:

Hello Sir ,

i did above task successfully before , but now i am suffering from data validation during submission using your technique...!!!

is there any way for data validation errors that cannot be submitted until the errors are resolved as when i click on field property for data validation it is showing disable !!!

then how can i submit data to sharepoint list with exact data validation !!! please help me out !!

thanks & regards,

Dipti Chhatrapati

# July 13, 2009 1:10 AM

infopath said:

Hi Dipti,

I am not sure I follow what you are asking - can you provide some additional detail as to what is/is not working?

Scott

# July 13, 2009 7:56 AM

dips23 said:

thanks for your fast reply !!!

well .. in second repeating table scenario u have shown input data functionality .

lets say , there is one field " email " ,  i want to apply data validation for email using custom pattern to enter proper value in email field...

then how can i do that , i hope u wud get my query !!

thankyou,

Dipti Chhatrapati.

# July 13, 2009 8:35 AM

amoghjain said:

hey infopath,

I made a new custom list and opened it in excel to edit it. Once in excel i copy pasted all the data I wanted and now, it works like a charm.

only problem while importing a spreadsheet is, you loose the ID column, which is really important while updating the SharePoint list(atleast according to me :D).

i still have one more question though..

is it possible i can assign a feild's value to a feild in repeating table??? is yes, can you tell me how...

once again, thanks for all your help and this blog.

# July 13, 2009 10:13 AM

infopath said:

Hi Dipti,

I am assuming you are entering/modifying the email address in the repeating table that is bound to your secondary data connection. As you have seen, data validation is not available through the UI in this case. So there are a couple of options:

1) Use code to copy all the rows from the secondary data connection to a mirrored data structure in your mail data source (this gives you additional flexibility in UI features.)

2) Use code on the changed event of the e-mail column from your list to test if the value entered by the user is valid. Here is a Knowledge Base article that provides a basic expression for checking an e-mail address:

http://support.microsoft.com/kb/308252

Then you would use code like this in the "Changed" event for your e-mail field in the repeating table:

NOTE: You will need to add the following "using" statement to your code: using System.Text.RegularExpressions;

public void MyContacts__Email_attr_Changed(object sender, XmlEventArgs e)

{

    if (!TestEmail(e.NewValue))

    {

    this.Errors.Add(e.Site, "Email Error", "Error in e-mail!");

    }

}

private bool TestEmail(string emailAddress)

{            

    Regex emailregex = new Regex("(?<user>[^@]+)@(?<host>.+)");

    Match m = emailregex.Match(emailAddress);

    return m.Success;

}

Scott

# July 13, 2009 1:28 PM

infopath said:

Hi amoghjain,

Sorry but I don't understand what you are asking in regard to assigning a value to a field? If you are referring to Excel, then I won't be able to help but if you are referring to how to do this from Infopath, then please review all the comments in this blog as there have been numerous questions on how to update existing values in a SharePoint list.

Scott

# July 13, 2009 1:31 PM

amoghjain said:

hey,

i have a secondary data source(New Entry), which updates a sharepoint list with 3 columns(ID, FirstName, LastName). I want to set a default value for the ID column, which depends upon another feild.

For example, i have a field name "Id_User" in the infopath form, and I want to assign this fields value in the ID field of the repeating table.

can you tell me how to do to this???

# July 13, 2009 2:14 PM

infopath said:

Hi amoghjain,

Thank you for the clarification. I am not a SharePoint expert but I don't believe their ID column is updateable. This is an auto-generated value when you add an item to the library or list. If you wanted to generate your own "ID" you would need to create your own "customID" column and this is what you would update.

If this works for you then you can use the "concat" function in a Rule to set your custom ID column. It would look something like this: concat(<SelectYourField>, "_Test")

Where "SelectYourField" would be where you use the "Insert field or group" button to select your field and "_Test" could be any text or another field.

Scott

# July 13, 2009 4:25 PM

dips23 said:

thank you very much !! scott !! :)

# July 14, 2009 1:02 AM

amoghjain said:

here is my code and now i can submit to a repeating table from any feild in infopath..:D(i am a co-op student)

function CTRL61_15::OnClick(eventObj)

{var root = XDocument.DOM;

var Definition_ID = root.selectSingleNode("/my:myFields/my:User_Definition_Modify/my:ID").text;

var User_Definition= root.selectSingleNode("/my:myFields/my:User_Definition_Modify/my:User_Modified_Definition").text;

var batch = XDocument.DataObjects["Update Item"].DOM;

batch.selectSingleNode("/Batch/Method/Field[@Name='ID']").text = Definition_ID;

batch.selectSingleNode("/Batch/Method/Field[@Name='DEFINITION']").text = User_Definition;

XDocument.DataAdapters["Modify"].Submit();

XDocument.UI.Alert( "Change Request has been successfully saved" );

}

# July 14, 2009 8:41 AM

infopath said:

Hi amoghjain,

Glad you have what you need!

Scott

# July 14, 2009 9:04 AM

bevy31 said:

Scott,

I was able to follow you instructions and get the form to work.  My problem or question is, does this form need to be published to SharePoint.  If I save or publish the form to my desktop and try to open the form back up once it is closed, I get the following error:

"The following DataObject either cannot be created or cannot be initialized: MyContacts

The query cannot be run for the following DataObject: MyContacts

InfoPath cannot run the specified query.

InfoPath either cannot connect to the data source, the service has timed out, or the server has an invalid certificate."

Can you tell me how to get this to work after you save and close the form.

Thanks,

Bev

# July 16, 2009 2:48 PM

infopath said:

Hi Bev,

That is an odd error that I don't believe is specific to what you are doing in regard to this post. Try this:

Test #1:

- Close all instances of InfoPath

- Click your Windows Start button and choose Run

- Enter this command: infopath /cache clearall

- Click OK

- Once InfoPath launches, close it and try to open your form again

If the above did not resolve the issue, try these steps:

- Create a new, blank XSN

- Add a receive data connection to the MyContacts list

- Display the Data Source Task Pane and drag MyContacts to your view as a repeating table

- Preview the form and make sure you see the data

- Save and close the form

- Simply double-click the saved XSN - what happens? If this works, then proceed with publishing this new XSN to your SharePoint site and test again from SharePoint - what is the result?

Scott

# July 16, 2009 5:48 PM

bevy31 said:

Does the InfoPath form have to be published to SharePoint, or can it be used offline and published to my computer?  Because if it has to be published to SharePoint, then that's probably why I am getting this error.

What I am trying to do is submit data to a SharePoint list using InfoPath, but not have the InfoPath form in SharePoint.   Is that possible?

# July 17, 2009 7:00 AM

infopath said:

Hi Bev,

No - the InfoPath Form Template (XSN file) does not have to be published to SharePoint...it can be published to your machine, network share, etc. and you will still be able to update the list.

Scott

# July 17, 2009 7:41 AM

bevy31 said:

I tried both your suggestions and it did not work.  I still get the same message.  It is unable to open the MyContact list once I save the form and close it.

# July 17, 2009 9:27 AM

bevy31 said:

I wonder could it be because we have to reach our SharePoint site using a Smart Card.  We have pick a certificate when we login, could this be preventing the retrieval of the list because it is wanting a certificate.

# July 17, 2009 9:42 AM

infopath said:

Hi Bev,

That may be the issue...I've not done much with Smart Card logon so I am not 100% sure.

Scott

# July 17, 2009 10:05 AM

Nmap said:

Hi Scott,

I followed your steps explained in "January 05, 2009" and can successfully submit the data and they show on the Sharepoint list. However the choice fields still show as Text, I need to manually type them while filling the form. Is there any way to choose between from A, B or C like explained in your example. Or I will be also happy if there will be A, B and C and I select them with a checkbox or radio button. Anything other than manually typing them is appreciated.

Thank you

# August 24, 2009 2:41 PM

infopath said:

Hi Nmap,

Did you follow the steps on January 09, 2009 for "Brynnie5209" ? In order to not get just text box controls for entering data, the design of the XSN will change completely. The steps to Brynnie5209 show how you can use different types of controls in your design. However, there is one caveat to this method: it will not work in browser forms. If you need to use different kinds of controls and the form will be used in the browser, you will need to use custom code for this process...which is also documented in and around this same date to other users.

Scott

# August 25, 2009 8:19 AM
Anonymous comments are disabled
Page view tracker