0

I found tons of samples with query for modified. But following keeps giving an exception that the query limit was to large (I gues it is the threshold limit).

var query = 
         $@"<View Scope='RecursiveAll'>
             <Query>
                <Where>
                 <Lt>                  
                     <FieldRef Name = 'Modified' /> 
                     <Value Type='DateTime'><Today OffsetDays='1'/></Value>
                 </Lt>
             </Where>
             </Query>
             <ViewFields></ViewFields>
             <RowLimit Paged='TRUE'>1000</RowLimit>
         </View>";

Kind of wierd when following works:

var query = 
        $@"<View Scope='RecursiveAll'>
            <Query>
               <Where>
                <Lt>
                    <FieldRef Name='ID' />
                    <Value Type='Integer'>1</Value>
                </Lt>
            </Where>
            </Query>
            <ViewFields></ViewFields>
            <RowLimit Paged='TRUE'>1000</RowLimit>
        </View>";

Complete code:

var query = 
$@"<View Scope='RecursiveAll'>
    <Query>
        <Where>
        <Lt>
            <FieldRef Name='ID' />
            <Value Type='Integer'>1</Value>
        </Lt>
    </Where>
    </Query>
    <ViewFields></ViewFields>
    <RowLimit Paged='TRUE'>1000</RowLimit>
</View>";

ListItemCollectionPosition position = null;
var camlQuery = new CamlQuery();
camlQuery.ViewXml = query; 
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

do
{
    using (var clonedCtx = ctx.Clone(ctx.Url))
    {
        List listWithClonedContext = clonedCtx.Web.Lists.GetByTitle(list.Title);
        clonedCtx.Load(listWithClonedContext);
        clonedCtx.ExecuteQueryWithIncrementalRetry(3, logger);

        ListItemCollection listItems = null;
        camlQuery.ListItemCollectionPosition = position;
        listItems = listWithClonedContext.GetItems(camlQuery);

        clonedCtx.Load(listItems);
        clonedCtx.ExecuteQueryWithIncrementalRetry(3, logger);        

        itemsResult.AddRange(listItems);       
        position = listItems.ListItemCollectionPosition;   
    }
}
while (position != null);
0

I'm not sure if you need to use a CAML query but I was able to get the modified date with the following CSOM code in Powershell:

$ItemId = 1
$FieldName = "Modified"
$ListName = "MyListName"

$List = $Context.Web.Lists.GetByTitle($ListName)
$Context.Load($List)
$Context.ExecuteQuery()
$ListItem = $List.GetItemById($ItemId)
$Context.Load($ListItem)
$Context.ExecuteQuery()
$Value = $ListItem.FieldValues.$FieldName

$Value has the date Modified value.

You could loop through for each item number.

Hope this helps.

| improve this answer | |

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.