Monday 7 May 2012

Cannot complete this action. Please try again

I got the error: "Cannot complete this action. Please try again. <nativehr>0x80004005</nativehr><nativestack></nativestack>"
The error itself doesn't say much about where its was thrown, but with some debugging I localized to be centered around an SPQuery on a list in SharePoint.

I checked everything, datatypes, permissions on the list and so forth.

However it turned out to be because I had nested three <Eq></Eq> statements in one <And></And> statement. It turns out that the <And></And> statement can only have to nested elements.
So if you like in my case has to filter on more than two parameters on the list build your caml something like this:


<Where>
  <And>
    <And>
      <Eq><FieldRef Name="UserId" LookupId="TRUE"/><Value Type="User" >{0}</Value></Eq>
      <Eq><FieldRef Name="SiteId" /><Value Type="Text">{1}</Value></Eq>
    </And>
    <Eq><FieldRef Name=\"TSPRelation\" /><Value Type=\"Text\">{2}</Value></Eq>
  </And>
</Where>


No comments:

Post a Comment