Home > Forum > Data sources > SHAREPOINT LIST - DELETE ITEM - FILTER BY COLUMN OTHER THAN ID

SHAREPOINT LIST - DELETE ITEM - FILTER BY COLUMN OTHER THAN ID
0

Dear Forum

I am trying to remove SharePoint list items in one of actions.
It works well when I pass a sharepoint item ID, but I do not have this available in webcon.
I would like to delete an item based on other column that I have. I tried CAML query below, but it does not work. Tried different columns, tried "" and '', tried contains but it does not work.
Any ideas how to do it properly?

<Where>
<Eq>
<FieldRef Name="Project Code"/>
<Value Type="Text">3153</Value>
</Eq>
</Where>

I have a field "Project Code", text type in Webcon, and "Project Code" text type in SharePoint. Filtering using this, does not work.
3153 in above example is a project code that I tried passing manually or through Form field value, no luck. I either get an error or nothing gets deleted

MVP

Hi Patryk,

the easiest option would be to create your CAML using the query builder:
https://www.spguides.com/caml-query-builder/

This way you could test at least the query. Another question I have is, whether you are working with folders. This may also make a difference.

@Przemysław
I'm quite sure your CAML is not valid. It's has been a few years when I needed to create a CAML but as far as I remember, if you have two conditions they have to be wrapped into and <and></and> or <or></or>.

Best regards,
Daniel

In reply to: Patryk Nawrocki

Thank You ,that's helpful, it works in a sense that it deletes the item. So good here.
But each time I'm getting an error, despite the fact that it gets deleted, and once I have an error next steps are not executed.


Error in On document save action Delete a list element.
Address of a Sharepoint list: /Lists/MDM Project listy
Caml query returns 1 items.

Hi, I have the same problem. When I use "Remove list item" action there is error message which shows how many rows were found and after clicking "close" all rows are deleted. I don't mind what is the point of this message.

I use the following query:

<Query>
<OrderBy>
<FieldRef Name='ID' />
</OrderBy>
</Query>

Anyway, I have also other problem with adding list items. Despite my SQL query gives many rows from 'wfelementdetails', only the first one is added to sharepoint list all the time. The only way is to use loop through the list which is pretty inefficient as takes quite a lot of time for longer lists.