0

I am trying to get the document details of a document with its GUID, but error says "Value does not fall within the expected range."

query.ViewXml = "<View Scope='Recursive'>" + _
"<Query>" + _
 "<Where>" + _
 "<eq>" + _
"<FieldRef Name=""GUID""/>" + _
"<Value Type='Guid'>" + _
"26V2766C-3563-41F3-9970-0EC245695014" + _
"</Value>" + _
"</eq>" + _
"</Where>" + _
"</Query>" + _
"<ViewFields>" + _
"<FieldRef Name='ID' />" + _
"<FieldRef Name='URL' />" + _
 "</ViewFields>" + _
"</View>"
1

Try this

 string guid = "put-your-guid-here";
    CamlQuery query = new CamlQuery();

query.ViewXml = String.Format("<View><Query><Where><Eq><FieldRef Name='UniqueId'/><Value Type='Guid'>{0}</Value></Contains></Where></Query></View>", guid);

Note that you need to reference the field by internal name, which is UniqueId. You also have XML syntax errors there. Remember that it's case sensitive and <eq> is not the same as <Eq>.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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