Domanda

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?

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top