CAML not Deleting or Updating List Items - InfoPath Dev
in

InfoPath Dev

CAML not Deleting or Updating List Items

Last post 10-14-2011 12:54 AM by Mingle. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 12-02-2008 07:03 AM

    CAML not Deleting or Updating List Items

    Hello everyone,

    I have a form which I would like to have create Calendar events if the events do not already exist in the Calendar List, and if they do already exist, update the existing items. I have, therefore two separate CAMLs - one for creating a new Item and the other for updating an existing one. I have tried both "cmd='Update'" and "cmd='Delete'", but both seem to produce the same result: it never deletes or overwrites the existing List Item - it simply creates a new one.

    Below are is the Update CAML and the code I am using. Please note that in my code I am successfully finding the existing Item's Row ID and passing it to the batch - it just simply wont use it or update with it.

    Please someone help me - as I am desperate to fix this issue. I am using InfoPath 2003 and SharePoint 2003.

    Update CAML:
    <?xml version="1.0" encoding="UTF-8" ?>
    <Batch OnError="Continue">
     <Method ID="1" Cmd="Update">
      <Field Name="ID" />
      <Field Name="Title" />
      <Field Name="Description" />
      <Field Name="EventDate" />
      <Field Name="EndDate" />
      <Field Name="ProjectManager" />
      <Field Name="ProjectSponsor" />
      <Field Name="DIPhase" />
      <Field Name="ProjectName" /> 
     </Method>
    </Batch>

    Code:
    Dim DI1updatebatch
    Set DI1updatebatch = XDocument.DataObjects("UpdateCAML").DOM
    DI1updatebatch.selectSingleNode("/Batch/Method/Field[@Name='ID']").nodeTypedValue = DI1rowtodelete
    DI1updatebatch.selectSingleNode("/Batch/Method/Field[@Name='Title']").text = DI1FieldTitle
    DI1updatebatch.selectSingleNode("/Batch/Method/Field[@Name='Description']").text = Description
    DI1updatebatch.selectSingleNode("/Batch/Method/Field[@Name='EventDate']").text = DI1EventDate
    DI1updatebatch.selectSingleNode("/Batch/Method/Field[@Name='EndDate']").text = DI1EndDate
    DI1updatebatch.selectSingleNode("/Batch/Method/Field[@Name='ProjectManager']").text = ProjectManager
    DI1updatebatch.selectSingleNode("/Batch/Method/Field[@Name='ProjectSponsor']").text = ProjectSponsor
    DI1updatebatch.selectSingleNode("/Batch/Method/Field[@Name='DIPhase']").text = "1"
    DI1updatebatch.selectSingleNode("/Batch/Method/Field[@Name='ProjectName']").text = ProjectName
    XDocument.DataAdapters("CalendarUpdate").Submit
    Set DI1updatebatch = Nothing

     

  • 12-04-2008 05:19 AM In reply to

    Re: CAML not Deleting or Updating List Items

  • 12-04-2008 07:01 AM In reply to

    Re: CAML not Deleting or Updating List Items

    Madhuri,

    Thanks for the information. Please forgive my beginner questions, but the link that can be constructed (on the top of the page under "Delete Items Based On User Input") - will it delete the item based on the ID input?

    If so, how would I go about obtaining the ListName? Is it the GUID or is it the Calendar name itself? I have tried using the GUID, both with normally and with the "%" portions for the brackets and dashes. Is there something I'm missing?

    Thanks again!

  • 01-12-2009 11:57 AM In reply to

    Re: CAML not Deleting or Updating List Items

     Can you post the code to retrive the " existing Item's Row ID"?

    Thanks

  • 05-11-2009 05:13 AM In reply to

    Re: CAML not Deleting or Updating List Items

    Did you ever find the code to do this?  I am trying to do the same and so far have set up a Data Connection to retrieve the ID for the list item I want, but am lost with the code?

  • 07-28-2009 03:28 AM In reply to

    • Daniels
    • Not Ranked
      Male
    • Joined on 07-28-2009
    • Melbourne, Australia
    • Posts 18

    Re: CAML not Deleting or Updating List Items

     

    jmagdziasz:
    I am trying to do the same and so far have set up a Data Connection to retrieve the ID for the list item I want, but am lost with the code?

    CAML data types must be in the correct format for all elements in the CAML query to execute.  If you are trying to set a Date/Time field with an invalid date format, the field will not be updated, and any elements after will also be ignored.

    I have found this to be a problem mainly when trying to update a Date/Time field (including the time component) in an existing SharePoint list item.  The only format that is supported in CAML is ISO 8601.  See InfoPath - CAML Date Time format in when submitting to a SharePoint list via a Web Service for details on how to convert date values to ISO 8601 standard for use in CAML.

    For details and an example of how to update existing SharePoint list items using a CAML query to the Lists web service see InfoPath - Update Existing SharePoint List Item Programmatically Using CAML.


     

    jswatter:
    Is it the GUID or is it the Calendar name itself?

    JSwatter, the ListName value should be the unencoded GUID (including hiphens, but not curly braces eg. "XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXX" ) of the required list. 

    Blogs:
    SharePoint Admin & Dev - SharePoint and InfoPath Development

    Web Development & Programming - Php, C#, .NET Framework, SEO Tips

    WebmasterHub.net - Free SEO, Webmaster Resources
  • 06-18-2010 12:08 AM In reply to

    Re: CAML not Deleting or Updating List Items

    Provided below are code samples written in C# to format an input as per SharePoint DateTime field. /* -- Format for Date Only Field -- */ private static String ToSPDate(String strDt) { if (strDt == String.Empty) return strDt; else return (Convert.ToDateTime(strDt)).ToString("yyyy-MM-dd"); } /* -- Format for DateTime Field -- */ private static String ToSPDateTime(String strDt) { if (strDt == String.Empty) return strDt; else return (Convert.ToDateTime(strDt)).ToString("yyyy-MM-ddTHH:mm:ssZ"); } http://www.mindfiresolutions.com/Format-Input-for-SharePoint-DateTime-field-186.php
    Cheers,
    Eliza
  • 10-14-2011 12:54 AM In reply to

    • Mingle
    • Not Ranked
    • Joined on 10-13-2010
    • Posts 3

    Re: CAML not Deleting or Updating List Items

    I got the same error when I want to delete a piece of list item.What's your lastet status?

    Below link show how to create a list item.

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

Page 1 of 1 (8 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.