urgent help Cam query to last updated record in SharePoint 2010 Client Object Model

Hi ,

im new to share point, by using below query getting  all items, but we need to get last updated item in share point.

Please any one suggest me , w

 Web web = clientContext.Web;
            List list = web.Lists.GetByTitle("IR");

            
            // CamlQuery to retrieve the items from the custom list
            CamlQuery query = new CamlQuery();
            query.FolderServerRelativeUrl = "/teas/E/_la/IR";
            
            // Get the items from the list
            ListItemCollection itemColl = list.GetItems(query);
            clientContext.Load(itemColl);

            // Execute the query to the server
            clientContext.ExecuteQuery();




  • Edited by anilraos 1 hour 20 minutes ago
July 30th, 2015 2:02am

Hi,

Put sort condition, where check Modified=ASC

Thanks,
Vivek
Please vote or mark your question answered, if my reply helps you

Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 2:06am

Hi

use the below code

camlQuery.set_viewXml('<View><Query>
<OrderBy><FieldRef Name='ID' Ascending='FALSE'/></OrderBy>
</Query><RowLimit>100</RowLimit></View>');

July 30th, 2015 2:14am

Hi,

SPQuery query = new SPQuery();
query.Query = @"<Where><IsNotNull><FieldRef Name='Title' /></IsNotNull></Where><OrderBy><FieldRef Name='Modified' Ascending='False' /></OrderBy>";
query.RowLimit = 1;

Order by "Modified" in descending order and limit row by 1.

  • Proposed as answer by SamDany 1 hour 23 minutes ago
Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 2:23am

Hi Rajendra, 

im using SharePoint 2010 Client Object Model, im unble to write to excute your code.

or im missing anything?

July 30th, 2015 2:25am

hi Rajendra 

as per your query i did not get the updated record, still getting all records 

            Web web = clientContext.Web;
            List list = web.Lists.GetByTitle("IR");

            
            // CamlQuery to retrieve the items from the custom list
            CamlQuery query = new CamlQuery();
            query.FolderServerRelativeUrl = "/teas/E/_la/IR";
              query.ViewXml = "<View><Query><OrderBy><FieldRef Name='Title' Ascending='FALSE'/></OrderBy></Query><RowLimit>100</RowLimit></View>')";
            // Get the items from the list
            ListItemCollection itemColl = list.GetItems(query);
            clientContext.Load(itemColl);

            // Execute the query to the server
            clientContext.ExecuteQuery();

Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 2:36am

Hi,

Refer to this.

https://msdn.microsoft.com/en-us/library/ff798388.aspx

Thanks,
Vivek
Please vote or mark your question answered, if my reply helps you

July 30th, 2015 2:42am


              query.ViewXml = "<View><Query><OrderBy><FieldRef Name='Title' Ascending='FALSE'/></OrderBy></Query><RowLimit>100</RowLimit></View>')";
            

 query.ViewXml = "<View><Query><Where><IsNotNull><FieldRef Name='Title' /></IsNotNull></Where><OrderBy><FieldRef Name='Modified' Ascending='False' /></OrderBy></Query><RowLimit>1</RowLimit></View>')";

I hope this will help you!

Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 3:05am

hi

use this.

using (ClientContext ctx = new ClientContext("url"))
{
    Web web = ctx.Web;
    List list =  web.Lists.GetByTitle("IR");
    var q = new CamlQuery() { ViewXml = "<View><Query><OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy></Query></View>"};
    var r = list.GetItems(q);
    ctx.Load(r);
    ctx.ExecuteQuery();                
}

July 30th, 2015 3:27am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics