| 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.
 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. |