CAML Query In Clause Problem

Hi, 
I'm using CAML query to retrieve data from custom list in SharePoint 2010 using In clause. I'm creating the <Value></Value> tag dynamically and its working fine. 
But sometimes I get a weird, no data fetch, error. I investigated on this and get to know that CAML query In clause only allow you to add 500 <Value></Value> in <Values> tag. The moment you'll entered 501 value it will not return any
data.
I need to resolve this problem and I can't send fetch request to SharePoint list if someone  is of the view that I should break the clause and fetch first 500 then again 500 and so on. 
Any help will be appreciated. 
Thank you

Hello Kashif,
Can't you create extra <OR> blocks when you have more than 500 values?
<OR>
<OR>
<First block 500 values>
<Second block 500 values>
</OR>
<Third block rest of the values>
</OR>
If this is not possible, maybe you can add more of your CAML query.
Jeroen Molenaar

Similar Messages

  • CAML query IN Clause limiation

    Hi All,
    I am trying to avoid joining the main document library list with another lookup custom list by first search the lookup custom list and get the document IDs to search them in the document library using IN clause.
    The problem with the IN clause is that it does not support more than 500 items, after than an exception is report "unable to handle search query".
    I am looking for the recommended solution for this problem.
    B.S. I have read an incomplete post "https://social.msdn.microsoft.com/Forums/sharepoint/en-US/350b2e9e-0c50-4887-85d0-b7e8bce9a3b8/caml-query-in-clause-problem?forum=sharepointdevelopmentprevious"
    that suggests dividing the IN statements into bulks of 500 items, but this did not work with me either.
    In my example:
    <Where> <In>
    <FieldRef Name="ProgId" />
    <Values>
    <Value Type='Number'>6</Value>
    -------------------more than 500 times.
    <Value Type='Number'>10006</Value>
    </Values>
    </In>
    </Where>
    Thanks,

    Hi,
    Please go through below link
    http://sharepoint.stackexchange.com/questions/80210/caml-query-limitation-of-values-in-in-operator
    Regards
    Soni K

  • CAML Query where clause on lookup field

    I'm trying to pull back values that are greater then 5 from my list. I'm using a lookup column that stores the numbers. That column is using a count of another lookup column in another list.
    <Query>
    <Where>
    <Gt><FieldRef Name='LookupColumn' /><Value Type='Lookup'>10</Value></Gt>
    </Where>
    </Query>
    I'm not getting any results or errors back. Is there a syntax error or something missing?

    You're missing a ">" on closing Value tag:
    <Value Type='Lookup'>10</Value
    should be:
    <Value Type='Lookup'>10</Value>

  • Problem with caml query in javascript

    hi friends
    i am using caml query to retrieve single list item
    ReviewQuery.set_viewXml('<view><query><Where><Eq><FieldRef Name=\'PNet_x002d_No\' /><Value Type=\'Text\'>'+id123+'</Value></Eq></Where></query></view>');
    my problem is if quried id is available in list it is showing properly. but if queried item is not there then it is showing other item in it.

    Hi,
    I suggest you debug the code and check if the variable value is valid.
    Here is a code snippet for your reference :
    <script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    _spBodyOnLoadFunctionNames.push("callCSOM");
    function callCSOM()
    $("#Button1").click(function()
    // Make sure the SharePoint script file 'sp.js' is loaded before your code runs.
    ExecuteOrDelayUntilScriptLoaded(sharePointReady, "sp.js");
    function sharePointReady()
    getListItems();
    var clientContext;
    var currentUser;
    var targetWeb;
    var message = "Web retrieved:";
    function getListItems()
    // Create an instance of the current context to return context information
    clientContext = SP.ClientContext.get_current();
    //Returns the list with the specified title from the collection
    var oList = clientContext.get_web().get_lists().getByTitle('list');
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml(‘<ViewFields><FieldRef Name='Title' /></ViewFields><Where> <Eq><FieldRef Name='Title' /><Value Type='Text'>12</Value></Eq> </Where>');
    this.collListItem = oList.getItems(camlQuery);
    clientContext.load(collListItem);
    clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
    function onRequestSucceeded()
    var listItemEnumerator = collListItem.getEnumerator();
    while (listItemEnumerator.moveNext())
    //Gets the current element in the collection
    var oListItem = listItemEnumerator.get_current();
    message += '___'+'Title: ' + oListItem.get_item('Title');
    message += '___'+'ID: ' + oListItem.get_item('ID');
    message += '________________________________________________';
    $("#div1").text(message);
    //the delegate of the method that is called when the request is executed unsuccessfully
    function onRequestFailed(sender, args)
    alert('Error: ' + args.get_message());
    </script>
    <input id="Button1" type="button" value="Run Code"/>
    <p/>
    <div id="div1">test</div>
    Also, you can build CAML Query in the CAML Designer:
    http://www.camldesigner.com/
    Feel free to reply if the issue still exists.
    Best regards
    Patrick Liang
    TechNet Community Support

  • Problem with lookup value by CAML query.

    I just cannot figure out what is wrong with my code that the query does not filter any item. It returns all items in the list. The RowLimit does work so I know the query is used. I wish someone can point out what is wrong in the query. Many thanks.
    SPList tList = cWeb.Lists[listName];
    SPQuery LookupQuery =
    new
    SPQuery();
    //LookupQuery.RowLimit = 5;
    LookupQuery.Query =
    "<Query><Where><Eq><FieldRef Name='ItemStatus' /><Value Type='Text'>New</Value></Eq></Where></Query>";
    SPListItemCollection iColl = tList.GetItems(LookupQuery);
    int n = iColl.Count;

    Try removing the starting and ending <Query> tags. Your CAML query assignment should look like below
    LookupQuery.Query = "<Where><Eq><FieldRef Name='ItemStatus' /><Value Type='Text'>New</Value></Eq></Where>";
    Ram Prasad Meenavalli | MCITP | MCTS SharePoint | MCPD SharePoint | http://www.spdeveloper.co.in

  • Retrieve All records and display in Report using CAML query in Report Builder if Parameter value is blank

    Hello Experts,
    i have created a report where i have one parameter field where user will pass parameter(e.g. EmpId). As per parameter record will fetched to report if no parameter is passed then it will display all records. I have done it by taking SqlServer Database as datasource.
    by using Following method
    Now i would like to do it by taking Sharepoint List as Datasource. For that what would be the CAML Query.
    Here is my existing CAML query.
    <RSSharePointList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <ListName>Employees</ListName>
      <ViewFields>
        <FieldRef Name="Title" />
        <FieldRef Name="FirstName" />
        <FieldRef Name="LastName" />
        <FieldRef Name="FullName" />
        <FieldRef Name="UserName" />
        <FieldRef Name="Company" />
      </ViewFields>
      <Query>
        <Where>  
    <Eq> 
        <FieldRef Name="Title" />
      <Value Type="Text">    
       <Parameter Name="EmployeeId"/>    
    </Value>
    </Eq>                  
        </Where>
      </Query>
    </RSSharePointList>
    The above code is working if i am passing an employeeId to Parameter. If nothing is passed, it is Not retrieving any record.
    Please suggest
    Thank you
    saroj
    saroj

    Your problem follows the well-established pattern of using an "All" parameter filter in SSRS. There are a few approaches depending on the size of your data. The easiest one is to return all data from CAML and then filter it within SSRS, the following thread
    provides some examples,
    http://stackoverflow.com/questions/18203317/show-all-records-some-records-based-on-parameter-value.
    Other options include passing all of the possible values within the CAML query when "All" is selected, using multiple Report Files to distinguish between both CAML queries, or to use multiple datasets with some logic to show/hide the correct one.
    Dimitri Ayrapetov (MCSE: SharePoint)

  • Join two list with condition using caml query in SharePoint 2013 with client object model

    Hi,
    Want to join two list to get all fields from both list.
    Am new to sharepoint and sharepoint 2013. Am working in sharepoint 2013 online apps. Am using context.executeQueryasync to load list and get items from list. Am able to get items from single list with caml query, but not able to get both list field values
    with joins.  I did lot of surfing..but not..
    Below is my code..
    ListName1 : "AssignedTasks"
    ListName2 : "Tasks"
     var assignedQueryTest = "<View><Joins><Join Type='INNER' ListAlias='Tasks'><Eq><FieldRef Name='TaskId' RefType='Id'/><FieldRef List='Tasks' Name='ID' /></Eq></Join></Joins>"
                    + "<ViewFields><FieldRef Name='TitleValue' /><FieldRef Name='ActionItemsValue' /></ViewFields>"
                    + "<ProjectedFields>"
                    + "<Field Name='TitleValue' Type='Lookup' List='Tasks' ShowField='Title' /><Field Name='ActionItemsValue' Type='Lookup' List='Tasks' ShowField='ActionItems' />"
                    + "</ProjectedFields>"
                    + "</View>";
                   var web = context.get_web();
                    var list = web.get_lists().getByTitle("AssingedTasks");
                    var myQuery = new SP.CamlQuery();
                    myQuery.set_viewXml(assignedQueryTest);
                    var myItems = list.getItems(myQuery, "Include(TitleValue,ActionItemsValue)");
                    context.load(myItems);
                    context.executeQueryAsync(function () { if(myItems.get_count()>0){....}
    }, errorCallback);
    Here am able to get "AssignedTasks" list field values but not able to get "Tasks" list field values. 
    Can you please help me to resolve the issue. Or new idea for join. I have add the condition also in the query.
    If anybody have good sample, please provide.
    Thanks,
    Pariventhan
    Pariventhan.S

    Hi Pariventhan,
    I don't know about join but I have a workaround of this problem.
    Declare one variable (itemcollection) globally. Load all the items "AssignedTasks" using context.load.
    In the success method call another CAML query using <IN> tag of the ID of the items from the second list (Assuming you have look-up column of the ID of the first list to the second list).
    If this is not clear to you then please let me know. If possible then I can provide code sample.
    Thanks,
    Aniruddha

  • My Library Column does not exist when I execute a Caml Query

    Hello,
    I am new to SharePoint programming.  I am trying to understand how I can access the documents in a Library Folder and obtain the field values for each document in the container.  With this in mind I have pieced together the following code from
    various posts that demonstrate how to to this:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint.Client;
    namespace ConsoleListItemsInFolder
        class Program
            static void Main(string[] args)
                ClientContext ctx = new ClientContext("http://mwp_lenovo");
                List DocumentsList = ctx.Web.Lists.GetByTitle("Claims Documents");
                CamlQuery camlQuery = new CamlQuery();
                camlQuery = new CamlQuery();
                camlQuery.ViewXml = "<View Scope=\"RecursiveAll\"> " +
                                "<Query>" +
                                "<Where>" +
                                            "<Eq>" +
                                                "<FieldRef Name=\"FileDirRef\" />" +
                                                "<Value Type=\"Text\">/Claims Documents/11111111 Stuart Little</Value>"
    +
                                             "</Eq>" +
                                "</Where>" +
                                "</Query>" +
                                "</View>"; 
                ListItemCollection listItems = DocumentsList.GetItems(camlQuery);
                ctx.Load(
                    listItems,
                    items => items
                    .Include(
                        item => item["Title"],
                        item => item["Claim Number"],
                        item => item["Policy Number"],
                        item => item["Policyholder Name"],
                        item => item["Document Type"]));
                ctx.ExecuteQuery();
                foreach (ListItem listItem in listItems)
                    Console.WriteLine("Title: {0}", listItem["Title"]);
                    Console.WriteLine("Claim NUmber: {0}", listItem["Claim Number"]);
                    Console.ReadLine();
    When I execute the code with the debugger ctx.ExecuteQuery(); throws the following error:
    Microsoft.SharePoint.Client.ServerException was unhandled
      Message=Column 'Claim Number' does not exist. It may have been deleted by another user.  /Claims Documents
      Source=Microsoft.SharePoint.Client.Runtime
      ServerErrorCode=-2147024809
      ServerErrorTypeName=System.ArgumentException
      ServerStackTrace=""
      StackTrace:
           at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
           at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
           at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
           at ConsoleListItemsInFolder.Program.Main(String[] args) in c:\Users\matt.paisley\Documents\Visual Studio 2012\Projects\ConsoleListItemsInFolder\ConsoleListItemsInFolder\Program.cs:line 37
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException: 
    These columns do exist in the Library as verified in Library Settings.  Many of the Library column names contain two words divided by a space.  Is this causing the problem?  Does SharePoint maintain a less offensive representation of the field
    name internally?  If so, how can I get it?
    If I run this code with only the title, then it runs fine.
    I Thank All in advance for any assistance that you can provided.
    Regards,
    Matt Paisley
    Matthew Paisley

    Hello
    In addition to Geetanjali Arora answer, change also those other columns
      item => item["Claim Number"],
      item => item["Policy Number"],
     item => item["Policyholder Name"],
     item => item["Document Type"]
    If you don't know the internal name of a column,
    go to the list containing the columns
    go to "list settings"
    scoll down to the "columns" section
    click on one of your columns et take a look a the url of the new page, you should found parameter "&Field=" => What is after is your field internal name (the one you should use in your CAML query)
    Best regards, Christopher.
    Blog |
    Mail
    Please remember to click "Mark As Answer" if a post solves your problem or
    "Vote As Helpful" if it was useful.
    Why mark as answer?

  • Javascript Caml Query join error

    Greetings, i'm getting an error in a caml query. I have 3 lists: Reuniones, Tareas, Gerencias. Tareas has a lookup to Reuniones (by ID) and Reuniones has a lookup to Gerencias (by Title). I'm trying to get all items in Tareas pointing to a Gerencias item
    "X", that is, all items in Tareas that has a Reuniones item with "X" as Gerencias lookup. Another requirement is that the Tareas item startdate has to be in a certain range.
    The problem is that my query is returning " Value does not fall within the expected range."
    My Query:
    <View>
    <Query>
    <Where>
    <And>
    <And>
    <Geq>
    <FieldRef Name='StartDate'></FieldRef><Value Type='DateTime'
    IncludeTimeValue='TRUE' StorageTZ='TRUE'>2014-02-01T02:00:00.000Z</Value>
    </Geq>
    <Leq>
    <FieldRef Name='StartDate'></FieldRef><Value Type='DateTime' IncludeTimeValue='TRUE' StorageTZ='TRUE'>2014-03-01T02:00:00.000Z</Value>
    </Leq>
    </And>
    <Eq>
    <FieldRef Name="Gerencia" List="Reuniones"/>
    <Value Type="Lookup">GerenciaExample</Value>
    </Eq>
    </And>
    </Where>
    </Query>
    <ViewFields>
    <FieldRef Name="Reunion" />
    <FieldRef Name="StartDate" />
    <FieldRef Name="Status" />
    </ViewFields>
    <ProjectedFields>
    <Field Name="Gerencia" Type="Lookup" List="Reuniones" ShowField="Gerencia" />
    </ProjectedFields>
    <Joins>
    <Join Type="Left" ListAlias="Reuniones">
    <Eq>
    <FieldRef Name="Reunion" RefType="Id" />
    <FieldRef List="Reuniones" Name="ID" />
    </Eq>
    </Join>
    </Joins>
    </View>

    Hi,
    Based on the error message, we can increase the value of the List View Lookup Threshold. 
    Go to the Central Admin > Application Management
    > Manage web applications>General Settings
    > Resource Throttling
    Here is a tool for you to check the query syntax.
    http://www.codeproject.com/Articles/458008/CAML-Query-Builder
    More information:
    List Join in SharePoint 2010 using CAML
    http://sujeewaediriweera.wordpress.com/2012/02/18/list-join-in-sharepoint-2010-using-caml/
    Best Regards
    Dennis Guo
    TechNet Community Support

  • Caml query to retrive keyword from rich text field

    hi friends
    i am using below caml query to retrieve data from title field and Rich text field(Definition) 
    <View>
    <Query>
    <Where>
    <And>
    <Or>
    <Eq>
    <FieldRef Name=\'Title\'/>
    <Value Type=\'Text\'>'+letter+'</Value>
    </Eq>
    <Contains>
    <FieldRef Name=\'Definition\' />
    <Value Type=\'Note\'>'+letter+'</Value>
    </Contains>
    </Or>
    <Neq>
    <FieldRef Name=\'status\' />
    <Value Type=\'Text\'>Not approved</Value>
    </Neq>
    </And>
    </Where>
    <OrderBy><FieldRef Name=\'Title\' /></OrderBy>
    </Query>
    </View>
    this query is working fine. But it is retrieving some extra fields also which doesn't have the queried string. and even it is retrieving keyword from image urls which are present in rich text field. 
    Please help me to retrieve key word from plain text of rich text field.

    Hi,
    According to your post, my understanding is that you want to use caml query to retrive keyword from rich text field
    By design, when specifying a ViewFields clause, values for these fields are returned, together with a few system columns like ID, Created and Modified.
    If you query rich text field, it will return the field with HTML tags.
    To retrieve key word from plain text of rich text field, you need to use regular expression to remove the HTML tags.
    You can use the code below:
    using (SPSite site = new SPSite("http://sitename"))
    using (SPWeb spWeb = site.OpenWeb())
    SPList spList = spWeb.Lists.TryGetList("ListName");
    SPQuery qry = new SPQuery();
    if (spList != null)
    qry.Query =
    @" <Where>
    <Contains>
    <FieldRef Name='Rich_x0020_Text' />
    <Value Type='Note'>caml</Value>
    </Contains>
    </Where>";
    qry.ViewFields = @"<FieldRef Name='Title' /><FieldRef Name='Rich_x0020_Text' />";
    SPListItemCollection listItems = spList.GetItems(qry);
    foreach (SPListItem item in listItems)
    string src = item["Rich_x0020_Text"].ToString();
    Regex htmlReg = new Regex(@"<[^>]+>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
    src = htmlReg.Replace(src, string.Empty);
    Console.WriteLine(src);
    Console.ReadKey();
    The result is as below:
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Ignore accents in a caml query in a webpart

    Hi everybody, please I need help with an issue.
    We have Sharepoint 2010 and the the server collation is Modern_Spanish_CI_AS.
    the SharePoint_Config is: Latin1_General_CI_AS_KS_WS 
    MySiteDB is: Latin1_General_CI_AS_KS_WS
    I have a webpart which  lists by CAML with information introduced by users in textboxs. My problem is with accents, my site is in spanish, and for example a user who is looking for an item in the list can put in the textbox "cuál canción" or
    "cual cancion", so when I execute the query I not always get the accurate results, because the information is already in in the list and i don know how it was inserted. 
    <where>
        <Contains>
            <FieldRef Name=\"Title\" />
            <Value Type=\"Text\">
                TEXT INSERTED BY USERS BY A TEXTBOX
            </Value>
        </Contains>
    </where>
    SPListItemCollection resultados = listaActual.GetItems(queryConsulta);
    is there an workarround which help me with this situation?
    thanks in advanced.
    Best regards.
    Carlos

    Hi carlospva,
    Thanks for posting your issue, Kindly try out below mentioned code snippet
    public static string Normalizarstring(this string cadena)
    StringBuilder sb = new StringBuilder();
    cadena.Normalize(NormalizationForm.FormD).ToCharArray().ToList()
    .ForEach(caracter => sb.Append((CharUnicodeInfo.GetUnicodeCategory(caracter) != UnicodeCategory.NonSpacingMark) ? caracter.ToString() : ""));
    return (sb.ToString().Normalize(NormalizationForm.FormC));
    Also, Check out below mentioned URLs for more details
    http://stackoverflow.com/questions/7842961/sharepoint-query-with-caml-and-accents
    https://social.msdn.microsoft.com/Forums/office/en-US/5be44758-ae8e-4a72-9276-31a1c5ffe75d/case-sensitive-caml-query?forum=sharepointdevelopmentlegacy
    http://msdn.microsoft.com/en-us/library/ms467521.aspx
    I hope this is helpful to you, mark it as Helpful.
    If this works, Please mark it as Answered.
    Regards,
    Dharmendra Singh (MCPD-EA | MCTS)
    Blog : http://sharepoint-community.net/profile/DharmendraSingh

  • Sharepont Designer saves AND/OR CAML Query groups incorrectly

    My objective is to display active tasks on a certain date: Started on or before and Due on or after; Started on or before and not Completed.  The date is provided via a webpart connection parameter.
    I used CAML Designer 2013 and SP CAML Query 2013 to verify and then modified the Query string for the Tasks WebPart in Sharepoint Designer as follows:
    <Query><Where>
    <Or>
    <And>
    <Leq><FieldRef Name="StartDate"/><Value Type="DateTime">{ParmMeetingDate}</Value></Leq>
    <Geq><FieldRef Name="DueDate"/><Value Type="DateTime">{ParmMeetingDate}</Value></Geq>
    </And>
    <And>
    <Neq><FieldRef Name="Status"/><Value Type="Text">Completed</Value></Neq>
    <Leq><FieldRef Name="StartDate"/><Value Type="DateTime">{ParmMeetingDate}</Value></Leq>
    </And>
    </Or>
    </Where></Query>
    However, when I save the page in SharePoint Designer, and edit the web page from the browser, the Filter criteria are:
    Start date Less than or equal to {ParmMeetingDate}
    AND DueDate Greater than or equal to
    AND Task Status is not equal to Completed
    OR Start Date is less than or equal to {ParmMeetingDate}
    If I correct the settings in the browser and save, the Query String in SPD is changed to:
    <Query><Where>
    <Or><Or>
    <And>
    <Leq><FieldRef Name="StartDate"/><Value Type="DateTime">{ParmMeetingDate}</Value></Leq>
    <Geq><FieldRef Name="DueDate"/><Value Type="DateTime">{ParmMeetingDate}</Value></Geq>
    </And>
    <Leq><FieldRef Name="StartDate"/><Value Type="DateTime">{ParmMeetingDate}</Value></Leq>
    </Or>
    <Neq><FieldRef Name="Status"/><Value Type="Text">Completed</Value></Neq>
    </Or></Where></Query>
    How can I get SPD/SP to save the CAML query correctly?

    Update:  Another effect of the problem outlined above was that no results were displayed for any parameterised filter values - regardless of the query.
    I came across a reference to the Server Render webpart attribute.  When this attribute is selected on the webpart a number of things happen:
    The Timeline at the top of the Tasks list view webpart is switched off
    The completed icon changes to a Yes/No value
    The filters work!!!
    Saving the filters works!!!
    The List View Tools tab appears in SharePoint Designer!!!
    I have no idea what the Server Render attribute is and/or why it is set off by default.  I don't why it affects the appearance of the List View Tools tab in the ribbon - I can't think of any reason why it should.  And I don't know why it affects
    the filter query or why it should...
    At a high level I presume the Server Render attribute tells sharepoint to process on the server rather than on the client.  It may make sense to pas the processing from the server to the client.  It makes no sense that this would restrict functionality
    (disable List View Tolls in SPD) or produce different results (no results in Filtered webpart).
    Do you know if this issue has been identified as a bug; has it been resolved?

  • Count of items ina list using CAML Query

    Hi,
    Thanks in Advance
    I'm using an app called blumshapiro to customize the tile in sharepoint 2013, I also have a requirement of getting the item count from the list which can be done by writing a CAML Query. Can anyone please assist me with the syntax to fetch the item count
    in caml Query.
    Regards,
    Niranjan

    Hi 
    There is nothing like item count in Camel query.You can get Required result using SPListItemCollection.Count
    Do a normal where clause having condition.
    SPQuery query = new SPQuery();
    string camlquery = @"<Query>
    <Where>
    <Eq>
    <FieldRef Name='Vendor_x0020_Product_x0020_Name'/>
    <Value Type='Text'>" + xpathresultBTADSLMAX + @"</Value>
    </Eq>
    </Where>
    </Query>";
    query.Query = camlquery;
    SPListItemCollection listItemCollection = list.GetItems(query);int count=0;if(listItemCollection !=null) { count=ListItemCollection.Count}MSDN reference
    http://msdn.microsoft.com/en-us/library/ms467521.aspx
    Regards, Rajendra Singh If a post answers your question, please click Mark As Answer on that ost and Vote as Helpful http://sharepointundefind.wordpress.com/

  • Sum and group by using CAML query

    Is there any way to get the SUM of values with group by ID using CAML query?
    I have a custom list, in that I have ID and Value columns as below
          ID         Value1      Value2
          1             10             4
          2              5              3
          1             15             2
          3             20             1
    I want to get result:
         ID          Value1        Value2
         1             25                6
         2             5                  3
         3             20                1
    I used CAML query:
    <View>
    <Query>
    <Where>
    <IsNotNull>
    <FieldRef Name="ID" />
    </IsNotNull>
    </Where>
    <GroupBy Collapse="FALSE">
    <FieldRef Name="ID" />
    </GroupBy>
    </Query>
    <ViewFields>
    </ViewFields>
    <Aggregations Value="On">
    <FieldRef Name="Value1" Type="SUM" />
    <FieldRef Name="Value2" Type="SUM" />
    </Aggregations>
    </View>
    But
    this query returns all the records
    that satisfy the condition <Where>.
    I
    do not correctly?

    You need to work with current view based aggregation. Please check below threads for your reference.
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/dda5735a-fecf-403f-9495-1b63617d2fbf/question-on-a-caml-query?forum=sharepointdevelopmentlegacy
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/24e88d6a-ee15-4d81-a5fe-504c7bd14e46/how-to-sum-a-column-value-using-caml-query?forum=sharepointdevelopment
    Hope this helps.
    My Blog- http://www.sharepoint-journey.com|
    If a post answers your question, please click Mark As Answer on that post and Vote as Helpful
    I've seen these
    issues and articles and do them, but
    does not work. I use object mozhel
    Sharepoint (javascript).

  • Value does not fall within the expected range while passing a spfieldlookupvalue in a caml QUERY

    i have to pass a column from master list -single line of text - and this will be the lookup of another column in another list
    splist1---> column1 [ free text]
    splist2--> column2  [ lookup column of the above list -splist1]
    now am writing a  caml query :
       objDisciNodeQuery.Query =
                                          string.Format(
                                       "<OrderBy>" +
                                         "<FieldRef Name='ID' />"
    +
                                      "</OrderBy>" +
                                       "<Where>" +
                                        "<And>" +
                                          "<Eq>" +
                                             "<FieldRef
    Name='somecolumn' />" +
                                             "<Value
    Type='Text'>{0}</Value>" +
                                          "</Eq>" +
                                          "<Eq>" +
                                             "<FieldRef
    Name='column2' LookupId='TRUE' />" +
                                             "<Value
    Type='Lookup'>{1}</Value>" +
                                          "</Eq>" +
                                         "</And>" +
                                       "</Where>", valueofsomecolumn, lookupidvalueofcolumn2);
                                        SPListItemCollection splistItemAssocCollec
    = null;
                                        splistItemAssocCollec = splist2.GetItems(objDisciNodeQuery);
    here it throws Value does not fall within the expected range
    Anyone has idea why i am getting this error, .
    any ideas  are appreciated.

    We can use lookup column in caml query link this
    <Where>
    <Eq>
    <FieldRef Name=’Departments’ LookupId=’TRUE’ />
    <Value Type=’Lookup’>10</Value>
    </Eq>
    </Where>
    Multi lookup column reference 
    http://naimmurati.wordpress.com/2013/12/03/multi-lookup-fields-in-caml-queries-eq-vs-contains/

Maybe you are looking for

  • How to deserialize xml with structure of abitrary nested layers of base class?

    let say i want to represent arithmetic expression using xml: <?xml version="1.0" encoding="utf-8" ?> <expr> <add> <num>10</num> <num>20</num> </add> </expr> and here is my classes to represent this: using System; using System.Collections.Generic; usi

  • Video files out of order

    I recently updated my iPod classic to version 1.0.3. I notice that the video files are no longer in alphabetical order. Can this be changed back?

  • Remove IE9 and reinstall IE8 on Windows 7

    Hi Guys, We have an issue were we have some Windows 7 running on it. We need to access an old System that doesn't support IE9 or any other bowser except IE8, IE7 or even IE6. Is there a way to uninstall IE9 or even install IE8 Along side IE9?

  • IDOC Messages

    Hi friends, Part of the project that I am working on is to improve all electronic orders, delivery and invoicing. The generated idoc errors are usually monitored on a daily bases. However, it is intended that after the user/purchase office/warehouse/

  • Slow Disk error when using Finale Cut

    I get a slow disk error when trying to play something in finale cut but when i try to verify disk and repair disk i get Error: Could not unmount disk. What is going on and how do i fix it?