Skip Ribbon Commands
Skip to main content

Ben There, Done That

:

SharePoint Ben > Ben There, Done That > Posts > Using the SharePoint web service to remove an item from a list
January 18
Using the SharePoint web service to remove an item from a list
For the last project I was working on, I needed to be able to delete an item from a SharePoint list using a Forms Service compatible InfoPath form. Due to the nature of the list, I needed to search for the item to delete based on the value of three different files and no column was unique. After several unsucessful attemps using various methods, I discovered that the only way you can use the List.asmx web service, is to delete an item based on the item ID (a hidden SharePoiint list column). The only way to do this in a forms services compatible form, is to write some code behind to perform the action. I used the following C# code in my InfoPath form and attached it to a button click event to remove the SharePoint list item based on the value in 3 fields in my InfoPath form. In the code below, any text in italics must be replaced with code specific to your particular setup of Infopath and SharePoint.
InfoPath_Delete_List_Item.jpg
Sample Code​

This solved my problem and I was successfully able to delete items from my SharePoint list. If anyone has any questions about the code or suggestions to make the code better, leave me a comment and I will respond as soon as I can.
 

 Comments

 
 
 
 
 
 
 
 
 
 
 

Glad you liked it. Would you like to share?

Sharing this page …

Thanks! Close

Add New Comment

 

Showing 0 comments

    Trackback URL
     
    blog comments powered by Disqus
     

     Pre-Disqus Integration Comments

     

    Comments

    Using the SharePoint web service to remove an item from a list

    Good post. i spent a lot of time trying to delete list item using other columns. your post helped me.
    Benjamin.SteginkNo presence information on 3/22/2011 8:34 AM

    Using the SharePoint web service to remove an item from a list

    Good post. it helped me. Thanks !!
    Benjamin.SteginkNo presence information on 3/22/2011 8:34 AM