[Solved] cannot complete this action. please try again. SharePoint CAML query

This SharePoint tutorial we will discuss how to solve cannot complete this action. please try again in SharePoint CAML query error. The error was coming in SharePoint Online, at the same time, you might the same error while working with CAML in SharePoint 2016/2013.

Recently, I was trying to retrieve SharePoint Online list items using the client-side object model (CSOM) with CAML query.

Below is the SharePoint CSOM code.

string fieldInternalName="Tsinfo_EmailId";
string fieldValue="fewlines4biju@gmail.com";

CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View><Query><Where><Eq><FieldRef Name='" + fieldInternalName + "'/></Eq><Value Type='Text'>" + fieldValue + "</Value></Eq></Where></Query></View>";
						
var itemColl = oList.GetItems(camlQuery);
ctx.Load(itemColl);
ctx.ExecuteQuery(); 

Cannot complete this action. please try again an error in SharePoint Online

I was searching for a solution but didn’t get anything.

Then I realized there is a problem in the CAML query syntax. I have added one extra before starting with <Value Type….

cannot complete this action. please try again. sharepoint online caml

So I modified the CAML query syntax to like below and it worked properly.

CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View><Query><Where><Eq><FieldRef Name='" + fieldInternalName + "'/><Value Type='Text'></Eq>" + fieldValue + "</Value></Eq></Where></Query></View>";
						
var itemColl = oList.GetItems(camlQuery);
ctx.Load(itemColl);
ctx.ExecuteQuery();

Now, the CSOM CAML code works perfectly.

Cannot complete this action. please try again error in CAML OR condition in SharePoint

If you are using OR condition in CAML like below, then you will get the same error. Because in CAML, you can have only a maximum of two conditions within an or in Condition.

<Where>
    <And>
       <Or>
         <Eq><FieldRef Name='Approver1' /><Value Type='User'>User1</Value></Eq>
         <Eq><FieldRef Name='Approver2' /><Value Type='User'>User2</Value></Eq>
         <Eq><FieldRef Name='Approver3' /><Value Type='User'>User3</Value></Eq>
        </Or>
      <Eq><FieldRef Name='FullName' /><Value Type='Text'>Bhawana Rathore</Value></Eq>
     </And>
 </Where>

The above CAML will through cannot complete this action. please try again.

Modify the code like below and it should work fine.

<Where>
  <And>
     <Or>
        <Eq>
           <FieldRef Name='Approver1' />
           <Value Type='User'>User1</Value>
        </Eq>
        <Or>
           <Eq>
              <FieldRef Name='Approver2' />
              <Value Type='User'>User2</Value>
           </Eq>
           <Eq>
              <FieldRef Name='Approver3' />
              <Value Type='User'>User3</Value>
           </Eq>
        </Or>
     </Or>
     <Eq>
        <FieldRef Name='FullName' />
        <Value Type='Text'>Bhawana Rathore</Value>
     </Eq>
  </And>
 </Where>

You may like following SharePoint CAML tutorials:

Hope this SharePoint CAML tutorial helps to solve cannot complete this action. please try again. SharePoint online error.

>