Programmatically add an item to a SharePoint list fails - InfoPath Dev Sign in | Join | Help in SharePoint Integration InfoPath (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads InfoPath Dev » InfoPath » SharePoint Integration » Programmatically add an item to a SharePoint list fails Programmatically add an item to a SharePoint list fails Last post 06-22-2010 06:21 AM by elizas. 11 replies. Page 1 of 1 (12 items) Sort Posts: Oldest to newest Newest to oldest Previous Next 06-11-2009 07:12 AM Gagan Joined on 06-02-2009 Posts 31 Programmatically add an item to a SharePoint list fails Reply Contact Hello all, I have followed this tutorial, with slight modifications to fit my needs but it seems like when i hit submit, nothing shows up in my sharepoint list. no errors or anything. my code seems alright, my GUID is correct, im not sure what to check from here. any ideas? 06-11-2009 01:54 PM In reply to Patrick Halstead Joined on 08-07-2006 Posts 5,112 Re: Programmatically add an item to a SharePoint list fails Mark as Not AnswerMark as Answer... Reply Contact Hi Goober, Why not ask the people on the site that posted the tutorial? We don't debug other people's stuff. By the way, the MVP that posted that article does post here. You can search for her name and maybe email her separately. Patrick HalsteadProject Manager at Qdabra 06-11-2009 11:10 PM In reply to symwongaton Joined on 03-11-2009 Posts 11 Re: Programmatically add an item to a SharePoint list fails Mark as Not AnswerMark as Answer... Reply Contact Hi, All code on BizSupportOnline.NET is tested before it goes online. While I don't guarantee that it will work nor give support for any code I publish, I do ensure that I go through all of the steps of each article before publishing them. Have you followed the exact steps as described in the article and tested the solution before making modifications? If not, I'd suggest doing that first to get a "plain vanilla" solution working before making your own modifications. If the solution does not work as described in the article, let me know; I'll then retest it. The issue you're having could be related to virtually anything. Did you rename a SharePoint list column after creating it? Are all of your field names correct? Also check the contents of your CAML batch before submitting it to the web service. You can also look whether anything has been logged in the SharePoint logs. And finally, you can search InfoPathDev on "CAML", because many people have had an issue similar to yours before. CAML is difficult to debug, which is why I generally don't recommend it as a way of submitting InfoPath data to a SharePoint list. There are other solutions available for submitting InfoPath data to a SharePoint list and which are much easier to debug. You may want to look into those. Hope this helps. S.Y.M. Wong-A-Tonhttp://www.bizsupportonline.net 06-12-2009 12:19 AM In reply to Patrick Halstead Joined on 08-07-2006 Posts 5,112 Re: Programmatically add an item to a SharePoint list fails Mark as Not AnswerMark as Answer... Reply Contact Thanks S.Y.M. for the reply here. Hope you are doing well! How do you like Office 2010? :) Patrick HalsteadProject Manager at Qdabra 06-12-2009 01:09 AM In reply to symwongaton Joined on 03-11-2009 Posts 11 Re: Programmatically add an item to a SharePoint list fails Mark as Not AnswerMark as Answer... Reply Contact No worries. I'm doing OK, thanks. I've not seen Office 2010, yet. You? :) S.Y.M. Wong-A-Tonhttp://www.bizsupportonline.net 06-15-2009 06:20 AM In reply to Gagan Joined on 06-02-2009 Posts 31 Re: Programmatically add an item to a SharePoint list fails Mark as Not AnswerMark as Answer... Reply Contact SYM, your plain version works great, i just tested. it seems like there is an error with the webservicesubmit in my modified version. i added a repeating table for my CAML, and the CAML does get populated with my custom info, so im assuming everything works great until then. I even created a whole new custom list in sharepoint and updated all connections plus a new GUID, but still no luck. i'll keep troubleshooting, and post if i have any results, in the meantime any info would help. EDIT: ok so i may have found something. I took my perfectly working example and added just one field. i updated the CAML, removed the previous CAML resource file, added the new one, created new code in VSTA for my new field, created a new collum in sharepoint and upon hitting submit, it now does nothing, doesnt even update what it use to. i tried both .innerxml and .value in the code. 06-15-2009 10:09 AM In reply to Gagan Joined on 06-02-2009 Posts 31 Re: Programmatically add an item to a SharePoint list fails Mark as Not AnswerMark as Answer... Reply Contact I have figured it out, the problem is that infopath/sharepoint is very anal. When i added an extra field to the working one, the problem was that it was called "Current Shift" with the space, and the space in the sharepoint list was the problem, (CurrentShift wouldnt work either) so i changed it in sharepoint, and in my code. even though i changed it to a working title, it still did not work, so i assume that even after changing the title, it doesnt work and you really need to create a whole new collum. so back to my original form, i changed all my titles to follow a standard of Only the leading char being Capitol, and no spaces, and it worked. plus i created a whole new sharepoint list from scratch. 06-15-2009 01:28 PM In reply to symwongaton Joined on 03-11-2009 Posts 11 Re: Programmatically add an item to a SharePoint list fails Mark as Not AnswerMark as Answer... Reply Contact Glad to hear you got it sorted. Yes, column names can be a pain to change in SharePoint once they've been created; and what you see on the front-end is not what SharePoint has stored on the back-end. So you have to keep them simple and get them right from the start. Good job, though, on figuring out what the problem was! S.Y.M. Wong-A-Tonhttp://www.bizsupportonline.net 06-15-2009 01:40 PM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Programmatically add an item to a SharePoint list fails Mark as Not AnswerMark as Answer... Reply Contact I recently (...erm, this very morning....) had a similar issue. This CAML Query Builder can help.... It is free, and when you chose to use UpdateListItems instead of a Query, you can see the exact syntax that is needed to add an item -- that includes any field name oddities. I believe that ShP gives the column a name when you first create it, and that name is kept for the life of the column. If you change the name in the list settings, all you are changing is the display, not the true value.... Hilary Stoupa 06-16-2009 05:21 AM In reply to Gagan Joined on 06-02-2009 Posts 31 Re: Programmatically add an item to a SharePoint list fails Mark as Not AnswerMark as Answer... Reply Contact So theoretically i can now change my sharepoint collum names from the unreadable (ex:Currentshift) to readable (ex: Current Shift) and my form should submit without any problems, without any changes? 02-08-2010 04:08 AM In reply to elizas Joined on 02-08-2010 Posts 14 Re: Programmatically add an item to a SharePoint list fails Mark as Not AnswerMark as Answer... Reply Contact You can think of a SharePoint List somewhat similar to a table present within a Database. As tables consist of different columns, a SharePoint List also comprises of different columns / fields and these fields can indeed have different attributes associated to it (like "Required field check", "Max Length", "Display Formats", etc). We can use SharePoint API to create these fields and associate the corresponding attributes programmatically within an existing List. Cheers,Eliza Filed under: Sharepoint experts india, Sharepo, Sharepoint web part development India, Sharepoint offshore development 06-22-2010 06:21 AM In reply to elizas Joined on 02-08-2010 Posts 14 Re: Programmatically add an item to a SharePoint list fails Mark as Not AnswerMark as Answer... Reply Contact Hi, Plz check the answer given below. We can use SharePoint API to create these fields and associate the corresponding attributes programmatically within an existing List. Provided below is a code snippet in C#.Net describing the same. using (SPSite oSPsite = new SPSite("http://Web-URL")) { oSPsite.AllowUnsafeUpdates = true; using (SPWeb oSPWeb = oSPsite.OpenWeb()) { oSPWeb.AllowUnsafeUpdates = true; /* get the SPList object by list name*/ SPList lst = oSPWeb.Lists["EmpList"]; /* create a Numeric field for EmpID */ SPFieldNumber fldEmpID = (SPFieldNumber)lst.Fields.CreateNewField( SPFieldType.Number.ToString(), Sharepoint migration India http://www.mindfiresolutions.com/Sharepoint-Support.htm Cheers,Eliza Filed under: sharepoint migration 2010 Page 1 of 1 (12 items) Copyright © 2003-2019 Qdabra Software. All rights reserved.View our Terms of Use.
Hello all,
I have followed this tutorial, with slight modifications to fit my needs but it seems like when i hit submit, nothing shows up in my sharepoint list. no errors or anything.
my code seems alright, my GUID is correct, im not sure what to check from here. any ideas?
Hi Goober,
Why not ask the people on the site that posted the tutorial? We don't debug other people's stuff.
By the way, the MVP that posted that article does post here. You can search for her name and maybe email her separately.
Thanks S.Y.M. for the reply here. Hope you are doing well! How do you like Office 2010? :)
SYM,
your plain version works great, i just tested. it seems like there is an error with the webservicesubmit in my modified version. i added a repeating table for my CAML, and the CAML does get populated with my custom info, so im assuming everything works great until then. I even created a whole new custom list in sharepoint and updated all connections plus a new GUID, but still no luck. i'll keep troubleshooting, and post if i have any results, in the meantime any info would help.
EDIT: ok so i may have found something. I took my perfectly working example and added just one field. i updated the CAML, removed the previous CAML resource file, added the new one, created new code in VSTA for my new field, created a new collum in sharepoint and upon hitting submit, it now does nothing, doesnt even update what it use to. i tried both .innerxml and .value in the code.
I have figured it out, the problem is that infopath/sharepoint is very anal.
When i added an extra field to the working one, the problem was that it was called "Current Shift" with the space, and the space in the sharepoint list was the problem, (CurrentShift wouldnt work either) so i changed it in sharepoint, and in my code. even though i changed it to a working title, it still did not work, so i assume that even after changing the title, it doesnt work and you really need to create a whole new collum. so back to my original form, i changed all my titles to follow a standard of Only the leading char being Capitol, and no spaces, and it worked. plus i created a whole new sharepoint list from scratch.
I recently (...erm, this very morning....) had a similar issue. This CAML Query Builder can help.... It is free, and when you chose to use UpdateListItems instead of a Query, you can see the exact syntax that is needed to add an item -- that includes any field name oddities.
I believe that ShP gives the column a name when you first create it, and that name is kept for the life of the column. If you change the name in the list settings, all you are changing is the display, not the true value....
So theoretically i can now change my sharepoint collum names from the unreadable (ex:Currentshift) to readable (ex: Current Shift) and my form should submit without any problems, without any changes?