Using Sharepoint Client Object Model with large libraries (more than 5000 elements)

Hi,
i have issue with acccessing large list with more than 5000 elements. I use a Sharepoint Client Object Model. 
It worked till yesterday when in the list was less than 5000. Now there is in the library more than 5000 elements. I have changed in the Central Administration limit for list from 5000 to 10000, but it helped only for list views. Script returns now 0 records.
var clientContext = new SP.ClientContext.get_current();
var currentListId =_spPageContextInfo.pageListId;
oList = clientContext.get_web().get_lists().getById(currentListId);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View Scope=\"RecursiveAll\">'+
'<Query>'+
'<Where>'+
'<And>'+
'<Eq><FieldRef Name=\"ContentTypeId\"/><Value Type=\"Text\">'+contentTypeId+'</Value></Eq>'+
'<And>'+
'<Eq><FieldRef Name=\"_x0040_Client\" LookupId=\"TRUE\" /><Value Type=\"Lookup\">'+client+'</Value></Eq>'+
'<Eq><FieldRef Name=\"_x0040_Company\" LookupId=\"TRUE\" /><Value Type=\"Lookup\">'+organisation+'</Value></Eq>'+
'</And>'+
'</And>'+
'</Where>'+
'</Query>'+
'<ViewFields>'+
'<FieldRef Name=\"ID\" />'+
'</ViewFields>'+
'</View>'+
'<RowLimit>100</RowLimit>');
camlQuery.ViewAttributes = "Scope='RecursiveAll'";
listItems = oList.getItems(camlQuery);
clientContext.load(listItems);
clientContext.executeQueryAsync(Function.createDelegate(this, onQuerySucceeded), Function.createDelegate(this, onQueryFailed));
Please advice how i can resolve this issue. Thanks a lot!!
from MSDN forum...

Thanks you, friends!
That to resolve my issue, i made next things:
1) turn off a limit items for my list
2) used SPQuery.ListItemCollectionPosition
property,
3) and corrected little mistake in my CAML Query.
May be a punkt #2 will be enough, don't you :)
from MSDN forum...

Similar Messages

  • How to get all previous versions page contents of a publishing page using SharePoint Client Object Model 2010

    How to get all previous versions page contents and other field values of a publishing page using SharePoint Client Object Model 2010?
    Thanks,
    Osmita

    Hi Osmita,
    Greetings.
    Here are the links that helps you. It has code attached to it.
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/a0d2ab40-99ba-4368-8505-1dc559ef6469/get-content-of-previous-version-of-page-sharepoint-2010?forum=sharepointgeneralprevious
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/faaf419f-997e-4150-9911-48cc375c3b46/how-to-get-previous-published-versions-of-publishing-pages-in-sharepoint-2010?forum=sharepointdevelopmentprevious
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • The remote server returned an error: (401) Unauthorized. while running client context using sharepoint client object model

    Hi,
    I have started using the client object model so that i do not have to go to sharepoint admins to perform some basic operations on remote server. While assigning list item level permission i am getting following error, could you please help. thanks.
    The remote server returned an error: (401) Unauthorized.
       at
    System.Net.HttpWebRequest.GetResponse()
       at
    Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
       at
    Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest()
       at
    Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
       at
    SetDowntimeItemPermission.SetPermission.Main(String[] args) in

    it seems your request was unauthenticated i'm not sure are you using a web application with FBA or desktop application my suggestion would be try to impersonate your request by passing network credentials (COM works on network credentials )
    NetworkCredential credentials = new NetworkCredential("username", "pwd", "domain");
    ClientContext context = new ClientContext("http://site-url");
    context.Credentials = credentials;
    Best Regards, Ashutosh | SharePoint World

  • Print multiple documents in sharepoint client object model

    Hi  All,
    I  have a content editor webpart which displays documents from document library using sharepoint client object model. 
    test1 test2 test3 test4 are documents from document library.
    I have requirement to print the selected documents in single click of print button.
    once I clicks on print button all the selected documents should get printed.
    Is there any way to achieve this....?
    Regards
    Srinivas
    srinivas

    Hi Srinivas,
    You can do this but it will be combination of ECMA and JS. First you need to get selected file name by ECMA script then call a java script function to print documents.
    Here is script to print all docs: http://stackoverflow.com/questions/7187400/printing-multiple-pdf-files-using-javascript
    Hope it could help
    Hemendra: "Yesterday is just a memory,Tomorrow we may never see"
    Whenever you see a reply and if you think is helpful, click "Vote As Helpful"! And whenever
    you see a reply being an answer to the question of the thread, click "Mark As Answer

  • SharePoint 2013 implement simple logout button which do not redirect to default sign out page using JavaScript client object model

    I am using windows authentication in my web application.
    My requirement is to implement a sign out button which will sign out the user without having him to close the browser and application should not ask him to login again.
    I tried following two options:
     1. Redirecting the user to default signout.aspx page " /_layouts/15/SignOut.aspx "
     2. Using "Sign In as a different user" URL " /_layouts/15/closeConnection.aspx?loginasanotheruser=true "
    In first case, user is redirected to default sign out page but he can press "Go Back to Site" link to revisit the site. Another major issue is that the user has to close the browser to sign out from the application completely, which is not desirable
    in my project requirement.
    In second case, the the current user is signed out of the application but if the user has saved the password in browser, he gets signed in automatically to the application.
    I also came across the solution where we replace the default sign out page with a custom sign out page, but I am not sure whether it can be implemented using JavaScript Client Object Model of SharePoint.

    Hi 
    I'm basically looking for the exact answer for the query.
    Meanwhile you need to go through the link mentioned below in order to understand how to do it.
    Debugging and Logging Capabilities in SharePoint 2010
    Indul Hassan
    Microsoft Community Contributor
    http://www.indulhassan.com
    You Snooze.. You Lose !!

  • Cannot download master page using managed client object model SharePoint 2010

    string siteUrl = "http://server:port/sites/demo";
    string fileServerRelativeUrl = @"/sites/demo/_catalogs/masterpage/v4.master";
    using (ClientContext context = new ClientContext(siteUrl)){ FileInformation fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(context, fileServerRelativeUrl);}
    File.OpenBinaryDirect() throws "The remote server returned an error: (404) Not Found" error. while Microsoft.SharePoint.Client.File f1 = web.GetFileByServerRelativeUrl(fileUrl);
                    context.Load(f1);
                    context.ExecuteQuery();this gives the file object.File.OpenBinaryDirect() works if I pass "/sites/demo/_catalogs/masterpage/TabViewPageLayout.aspx" as fileServerRelativeUrl.Both the files are present in Master Page Gallery.File.OpenBinaryDirect() doesn't work if I pass any of ".master" file in the master page galleryPlease let me know whether downloading the master pages is supported using managed Client object model. 

    Hi,
    If don't change the default config, We are unble to download master page.
    It's better to create your own (perhaps based on the default.master) and use that master page.
    also,make sure there's no a permission issue on the website.
    Thanks
    Guangchao chen
    TechNet Community Support

  • Error in Application.Run(DisplayLoginForm) and Remote Authentication in SharePoint Online Using the Client Object Model

    Hi guys
    I Think that is a simple error, but I don’t have enough knowledge in .NET apps.
    I make an console app that use Remote Authentication in SharePoint Online Using the Client Object Model, that a I downloaded from MSDN.
    This App run ok.
    But when I like to make a Windows From App. This component send me an error in Application.Run(DisplayLoginForm)
    This err msg :
     An unhandled exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll
    Additional information: Starting a second message loop on a single thread is not a valid operation. Use Form.ShowDialog instead.
    Is there any way to use a form inside a windows form?
    Thank in advance
    Ramiro
    Ramiro B

    Hi,
    Based on the error message, please do as following:
    1. Check your code logic below:
    void btn_Click(object sender, System.EventArgs e)
    Thread t = new Thread(StartMyForm);
    t.TrySetApartmentState(ApartmentState.STA);
    t.Start();
    public static void StartMyForm()
    Application.Run(new MyForm(..));
    2.Try to add the following code line in your code.
    Application.Restart();
    If the issue still exists, please provide your requirement and code for a further research.
    Best Regards
    Dennis Guo
    TechNet Community Support

  • CAML Query to get specific item in folder based on dropdown value using Javascript client object model

    Hi,
    I am using the Javascript Client object model.
    I have a custom list and a custom document library.
    Custom list contains 2 columns - dlName , dlValue
    The document library contains 2 folders - "folder1" ,  "folder2" and contains some images.
    The image name starts with the "dlValue" available in the custom list
    I am using a visual webpart and using javascript client object model.
    I am trying to achieve the below functionality:
    1) Load a dropdown with the custom list.
    2) set the image based on the value in dropdown.
    I have achieved the first option, I have set the dropdown, but not sure how to query the folder and set the image.
    Below is the code i have used so far:
    //In Visual webpart
    <select id="ddlTest" >
    </select>
    <br/>
    <div id="PreviewLayer">
    <img id="imgPlaceHolder" runat="server" alt="Image" title="imgPlaceHolder" src=" " />
    </div>
    // In Javascript file
    function RenderHtmlOnSuccess() {
    var ddlTest = this.document.getElementById("ddlTest");
    ddlTest.options.length = 0;
    var enumerator = this.customListItems.getEnumerator();
    while (enumerator.moveNext()) {
    var currentItem = enumerator.get_current();
    var dropdownValue = currentItem.get_item("dlValue");
    ddlTest.options[ddlTest.options.length] = new Option(currentItem.get_item("dlName"), dropdownValue);
    setImage(dropdownValue); // Not sure how to query the folder and set the image based on value.
    // Also if dropdown value is changed, corresponding image should be shown
    How to query the folder and based on dropdown value, show the image? Also, how to handle the dropdown value change?
    Thanks

    Hi,
    Here are two links for your reference:
    Example of how to Get Files from a Folder using Ecmascript \ Javascript client object model in SharePoint 2010
    http://sharepointmantra.wordpress.com/2013/10/19/example-of-how-to-get-files-from-a-folder-using-ecmascript-javascript-client-object-model-in-sharepoint-2010/
    SP2010 JSOM Client Object Model: How to get all documents in libraries including all folders recursively
    http://sharepoint.stackexchange.com/questions/70185/sp2010-jsom-client-object-model-how-to-get-all-documents-in-libraries-including
    In SharePoint 2013, we can also use REST API to achieve it.
    http://msdn.microsoft.com/en-us/magazine/dn198245.aspx
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • Add multiple people using Javascript Client Object Model

    I am trying to add multiple people to a SP column of type Person/Group i.e. people picker. I am able
    to add one successfully using their userId, but HAVE no clue how to do that for multiple people. Here is the code for one user:
    function UserDrop(e, toElement, listGuid, columnName) {
    //EcmaScript Client Object Model
    var ctx = new SP.ClientContext.get_current();
    var list = ctx.get_web().get_lists().getById(listGuid);
    var item = list.getItemById(elementId);
    //columnName is of type person/group and I am adding user //whose userId is 7
    item.set_item(columnName, 7);
    item.update();
    // asynchronous call
    ctx.executeQueryAsync(
    function () { toElement.innerHTML = userLinkHtml; },
    function () {alert ("Error")}
    return false;
    This works great and I can add user whose userId is 7, however I want to add multiple people like let's say users of user Ids 7 and 8. 
    Any ideas or help will be greatly appreciated. 
    There is a thread on this one but that's from .net COM which could accessed here: http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010general/thread/5183e87c-ee1d-4594-9492-0dfdf6616cce
    7929

    Hi ,
    Can somebody let me know how the same(assigning the array values to lookup value field) can be achieved with multi-select lookup value. SP.FieldLookUpValue do not have any such methods like fromUser. Please help. Please find my code block below
    clientContext = new SP.ClientContext.get_current();
    if (this.clientContext != undefined && clientContext != null) {
    var webSite = clientContext.get_web();
    oList = webSite.get_lists().getByTitle("Add New User");
    $.urlParam = function(name){
    var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
    return results[1] || 0;
    var itemid = parseInt($.urlParam('ID'));
    var item = oList.getItemById(itemid);
    var users = new Array();
    users.push(SP.FieldLookupValue.set_lookupId(1));
    users.push(SP.FieldLookupValue.set_lookupId(2));
    item.set_item('Responsibility', users);
    item.update();
    clientContext.executeQueryAsync(Function.createDelegate(this, this.success), Function.createDelegate(this, this.failed));
    also i cant use managed client object model.. so pls let me know how to achieve the same using javascript client object model
    Ranjani.R

  • Add attachments to List Item using JavaScript Client object model in SP2010

    Hi All ,
    I have created custom form for submitng data in list using javascript client object model/jquery .
    Now I want to add option to uplaod multiple attachments to that list item also .
    Is there option with client object model for uplaoding attachment.
    Thanks
    M
    Manesh G

    Can you try this and let me know
    using (SPSite _site = new SPSite(SPContext.Current.Site.Url))
        using (SPWeb _web = _site.OpenWeb())
         //Let's suppose your Item Id is 1
         int ItemId = 1;
         SPList  oList = _web.Lists["EmployeeList"];
         SPListItem  _item = oList.GetItemById(ItemId);
         if (FileUpload1.HasFile)
               _web.AllowUnsafeUpdates = true;
              Stream fs = FileUpload1.PostedFile.InputStream;
              byte[] _bytes = new byte[fs.Length];
              fs.Position= 0;
              fs.Read(_bytes, 0, (int)fs.Length);
              fs.Close();
              fs.Dispose();
              _item.Attachments.Add(FileUpload1.PostedFile.FileName, _bytes);
              _item.Update();
              _web.AllowUnsafeUpdates = false;

  • Through SharePoint Client Object model, how to make color coded events on Sharepoint Calendar

    Hi,
    Through SharePoint Client Object model, how to make color coded events on Sharepoint Calendar.
    Plese share your knowledge.
    Regards
    Tharak

    Hi,
    According to your post, my understanding is that you wanted to make a color events Calendar.
    We can achieve it using the OOB method by creating the Calendars Overlay.
    http://summit7systems.com/color-code-calendar-events-in-sharepoint/
    You can also use the JavaScript to achieve it.
    http://spsawyer.wordpress.com/2013/07/18/sharepoint-color-calendar/
    http://www.planetwilson.co.uk/sharepoint-2013-colour-calendar-v2/
    more reference:
    http://usermanagedsolutions.com/SharePoint-User-Toolkit/Pages/Color-Coding-Calendar-List.aspx
    http://blog.pathtosharepoint.com/2010/04/06/tutorial-add-color-coding-to-your-sharepoint-2007-calendar-in-15-minutes/#comment-7231
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • Read versions of comments field using javascript client object model

    Hi,
     Does someone knows how to Read versions  of comments field in 'tasks' list using javascript client object model?
    Thanks
    Manvir

    Hi,
    According to your description, I know you want to read versions of comments field.
    We can use the
    SPServices to achieve it. The below code for your reference:
    $().SPServices({
    operation: "GetVersionCollection",
    async: false,
    strlistID: "tester",
    strlistItemID: 1,
    strFieldName: "comments",
    completefunc: function (xData, Status) {
    $(xData.responseText).find("Version").each(function(i) {
    console.log("Name: " + $(this).attr("Information") + " Modified: " + $(this).attr("Modified"));
    More information:
    http://spservices.codeplex.com/releases/view/81401
    Best Regards,
    Dennis Guo

  • Sharepoint client object model - Pull files from one site and move to another

    Dear All,
    I am using client object model to retrieve files of certain criteria using caml query and copy them to some other site using 
    client object model. There is no exception being thrown, but the application is not performing either. No files are being copied to destination. Here is the code. Please advise.
    The message box that I have kept at the end is being displayed, but no files are being copied.
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Net;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Microsoft.SharePoint;
    using SP = Microsoft.SharePoint.Client;
    namespace WindowsFormsApplication2
        public partial class Form1 : Form
            public Form1()
                InitializeComponent();
            private void Form1_Load(object sender, EventArgs e)
            private void button1_Click(object sender, EventArgs e)
                SP.ClientContext srcContext = new SP.ClientContext(textBox1.Text);
                srcContext.Credentials = new NetworkCredential(textBox3.Text, textBox4.Text, textBox5.Text);
                SP.ClientContext destContext = new SP.ClientContext(textBox2.Text);
                destContext.Credentials = new NetworkCredential(textBox3.Text, textBox4.Text, textBox5.Text);
                SP.CamlQuery camlQuery = new SP.CamlQuery();
                camlQuery.ViewXml = "<View Scope='RecursiveAll'><Query><Where><And><Geq><FieldRef Name='Created' /><Value IncludeTimeValue='TRUE' Type='DateTime'>2013-01-01T04:16:20Z</Value></Geq><And><Lt><FieldRef
    Name='Created' /><Value IncludeTimeValue='TRUE' Type='DateTime'>2013-12-31T04:16:43Z</Value></Lt><Or><Eq><FieldRef Name='Document_x0020_Classification' /><Value Type='Choice'></Value></Eq><Eq><FieldRef
    Name='Document_x0020_Classification' /><Value Type='Choice'>Case Studies</Value></Eq></Or></And></And></Where></Query></View>";
                SP.Web oWebsite = srcContext.Web;
                srcContext.Load(oWebsite, website => website.Webs);
                srcContext.ExecuteQuery();
                SP.Web dWebsite = destContext.Web;
                destContext.Load(dWebsite);
                destContext.ExecuteQuery();
                foreach (SP.Web web in oWebsite.Webs)
                    MessageBox.Show(web.Title);
                    foreach (SP.List list in web.Lists)
                        if (list.BaseType.ToString() == "DocumentLibrary")
                            MessageBox.Show(list.Title);
                            SP.ListItemCollection collListItem = list.GetItems(camlQuery);
                            srcContext.Load(collListItem);
                            srcContext.ExecuteQuery();
                            foreach (var doc in collListItem)
                                        SP.File f = doc.File;
                                        srcContext.Load(f);
                                        srcContext.ExecuteQuery();
                                        string destLibrary = "shared Documents";
                                        string nLocation = dWebsite.ServerRelativeUrl.TrimEnd('/') + "/" + destLibrary.Replace(" ", "")
    + "/" + f.Name;
                                        SP.FileInformation fileInfo = SP.File.OpenBinaryDirect(srcContext, f.ServerRelativeUrl);
                                        SP.File.SaveBinaryDirect(destContext, nLocation, fileInfo.Stream, true);
                MessageBox.Show("Completed");
    sk.Rakhishma

    Hi,
    To copy files from one site collection to another site collection, the simplest way is to open document library in windows explorer view.
    Go to document library, click library tab, click open with explorer.
    You can open the document library1 in explorer then copy the files which you want to paste to another site collection
    document library2, then open the document library2 in explorer to paste the documents.
    Besides, there are other method:
    https://social.msdn.microsoft.com/Forums/office/en-US/67282348-25c7-4bd0-9d95-61024c6892f9/how-we-move-a-document-library-from-one-site-collection-to-another-sitecollection?forum=sharepointgeneralprevious
    https://social.msdn.microsoft.com/Forums/sharepoint/en-US/8c112d85-1ab8-426b-be37-d010cf8647fe/copy-a-list-from-one-site-collection-to-another-using-web-service
    Best Regards,
    Lisa Chen
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Get current item id using JavaScript Client Object Model

    I have a client query that query SharePoint list Items. Lets say it is a document library. I need to get the list item id of each. 
    I can query the Title of the document using this syntax.
    ctx.CurrentItem['Title']
    But when I try 
    ctx.CurrentItem['ID']
    for list item ID, it does not give a value. How can I solve this?

    Hi Malin,
    If you're using the JavaScript Client Object Model, try using the SPListItem.get_item('key') method as in the example below:
    <script>
    ExecuteOrDelayUntilScriptLoaded(function(){
    var arrIds = [];
    var clientContext = new SP.ClientContext();
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml('<View><Query></Query></View>');
    var items = clientContext.get_web().get_lists().getByTitle("Your List Title Here").getItems(camlQuery);
    clientContext.load(items);
    clientContext.executeQueryAsync(Function.createDelegate(this,function(){
    var itemEnumerator = items.getEnumerator();
    while(itemEnumerator.moveNext()){
    var itemId = itemEnumerator.get_current().get_item('ID');
    arrIds.push(itemId);
    alert(arrIds);
    }), Function.createDelegate(this, function(){
    alert("something went wrong");
    },"SP.js");
    </script>

  • Get current loggedin user using silverlight client object model SharePoint 2010?

    Hello,
    How can i get the current loged in user of sharepoint 2010 in silverlight4.XX  version by programtically in C#?
    Thanks
    Lovkesh Patel

    Hi,
    ClientContext clientContext = ClientContext.Current;
    clientContext.Load(clientContext.Web, s => s.CurrentUser);
    clientContext.ExecuteQueryAsync((sender, args) => {
    var currentUser = clientContext.Web.CurrentUser; }, null);
    For more information:
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.web.currentuser.aspx and
    http://stackoverflow.com/questions/3441794/retrieve-current-user-login-in-sharepoint-from-a-silverlight-application
    Hope this helps you
    Senior Sharepoint Developer,STS [email protected]

Maybe you are looking for