0

I was retrieving data from sharepoint list. When my query was less that time no issues to display the data. But more than 300 or conditions invloved in that query exception is coming "value does not fall within the expected range"

 SPList olistLegal = oWeb.Lists.TryGetList("TestList");
                                        SPQuery LEoquery = new SPQuery();

                                        LEoquery.Query = "<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>" + Legalentityname + "</Value></Eq></Where>";
                                        // SPListItemCollection oItemLegalentitycoll = olistLegal.GetItems(LEoquery);
                                        foreach (SPListItem oItemLegalentitycoll in olistLegal.GetItems(LEoquery))
                                        {
                                            string contractid = Convert.ToString(oItemLegalentitycoll["ContractID"]);
                                            if (string.IsNullOrEmpty(LegalEntityquery) == true)
                                            {
                                                LegalEntityquery = "<Eq><FieldRef Name='ContractID' /><Value Type='Text'>" + contractid + "</Value></Eq>";
                                            }

                                            else
                                            {
                                                LegalEntityquery = "<Or>" + LegalEntityquery + "<Eq><FieldRef Name='ContractID' /><Value Type='Text'>" + contractid + "</Value></Eq></Or>";
                                            }
                                        }

i was receiving this error in my webpart.

enter image description here

2

1 Answer 1

1

Since you are not allowed to put more than two conditions in one condition group (And | Or) you have to create an extra nested group.

1
  • Actually we don't have any conditions to use only these many times. we can use n times OR condition in caml Query but use it as Nested Group.
    – san
    Sep 13, 2017 at 6:30

Your Answer

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

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