0

I want to use CAML query to delete elements from a SharePoint list.

Right now it deletes element if they have a specific text in their title:

camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name=\'Title\'/>' +
        '<Value Type=\'Text\'>'+statID+'</Value></Eq></Where></Query></View>');

What does one have to add to the camlQuery above when it should delete elements if they have a specific text in a column playerID? (So, the element should have a specific title and a specific playerID)

I tried different things, but can't seem to figure it out. Can someone help me?

1
  • What is the internal name and data type of your playerID field? Commented Apr 3, 2020 at 12:50

1 Answer 1

2

Assuming playerID field is of type Single Line of Text (If data type is different then let me know. I will change query accordingly),

Try your query in below format:

<View>
    <Query>
        <Where>
            <And>
                <Eq>
                    <FieldRef Name='Title'/>
                    <Value Type='Text'>statID</Value>
                </Eq>
                <Eq>
                    <FieldRef Name='playerID'/>
                    <Value Type='Text'>playerID</Value>
                </Eq>
            </And>
        </Where>
    </Query>
</View>

Note: You need to use the internal name of your column in place of playerID at the line <FieldRef Name='playerID'/>.

Reference: And Element (Query).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.