CAML Query to Sort SharePoint list items based on Modified date

hi ,
can we sort sharePoint list items based on 'Modified' column, the sorting should be done up to milliseconds level.
currently i am using CAML query as below
<OrderBy><FieldRef Name='Modified' Type='DateTime' IncludeTimeValue='TRUE' Ascending='False'/></OrderBy>but its not considering milliseconds while sorting.
Thanks and Regards,
venkatesh.

Veda, thanks but I'm not really a hardcore C# coder.
We found more elegant solution was to create a List View which returns all records that should be deleted, based on our own custom deletion criteria, and then create an very simple SSIS Package in Visual Studio using the
Sharepoint Connectors for SSIS to delete all Sharepoint List Items returned from that List View. The Sharepoint Destination Connector has a delete operation.
This worked for us and didn't require any coding.

Similar Messages

  • Filter SharePoint list items using CAML query as same as Like operator in SQL Server.

    Hi ,
    I have filtered SharePoint list items based on Name using CAML query <Contains> . Now I have a new requirement is to filter list items using Like operator in SQL. But Like operator is not in CAML.
    How do I filter list items using CAML as same as Like operator in SQL.
    Please let me know.
    Thanks in Advance.

    Did you try using <Contains>?
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/15766fd5-50d5-4884-82a1-29a1d5e38610/caml-query-like-operator?forum=sharepointdevelopmentlegacy
    --Cheers

  • Update a list item based sort order of created by column value

    HI
    using powershell script how to sort a list column before update a list  item.
    here i created a document library and uploaded some documents and update ProcessNo column based sort order of created column
    value.
    Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
    $webURL = "http://tspmcwfe:91" $listName = "Courts"
    Get the SPWeb object and save it to a variable
    $web = Get-SPWeb $webURL
    $list = $web.Lists[$listName] 
    $items = $list.items
    Go through all items
    foreach($item in $items)
    $item["ProcessNo"] = 1
    $item.Update()
    $web.Dispose()

    Hi,
    According to your description, my understanding is that you want to sort the list items order before updating items using PowerShell.
    I suggest you can use the Sort-Object command to sort the list items.
    Here are some detailed articles for your reference:
    Better SharePoint Lists and List Items in PowerShell
    Sort-Object
    Thanks
    Best Regards
    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]

  • Open a SharePoint List item in Modal Pop up in SP 2013 fails after you filter or sort the list

    Sorry for the long post. This has been killing me. I had this script working perfectly fine in SharePoint 2010 (online) and basically i have a source custom list (list A) with a hyperlink column and a Destination List with say title and my name.
    Source List (list A) looks like this with these 2 columns
    Title    Test Link
    A         Link 1
    B         Link 2 
    C         Link 3
    Each of these links link to the actual list item in the destination list, so for example, link 1 is/sites/2013DevSite/Lists/Destination%20List/EditForm.aspx?ID=1
    So basically i want anytime the Link are clicked that point to another list's item to open in a modal dialog and the script below worked perfectly fine in SharePoint 2010 (online)
    <script language="javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
    <script language ="javascript" type="text/javascript">   
    jQuery(document).ready(function() {
    jQuery('a[href*="EditForm.aspx"]').each(function (i, e) {
    // Store the A tag's current href in a variable
    var currentHref = jQuery(e).attr('href');
    jQuery(e).attr({
    'href': 'javascript:void(0);', 
    // Use the stored href as argument for the ShowInModal functions parameter.
    'onclick': 'ShowInModal("' + currentHref + '");'
    function ShowInModal(href) {
    SP.UI.ModalDialog.showModalDialog({title: "Edit Item", url: href});    
    </script>
    All it does is find the href tags for that particular value Editform.aspx and the pop modal works in SP 2010 online. So the site page is designed in such a way there is a content editor web part with the reference to this javascript file and the sharepoint
    list is right beneath it and this worked perfectly opening in modal windows in SP 2010.
    Since migration to 2013, this is what exactly happens
    1.) when you come to the site page, the modal works,
    2.) If you filter or sort on say the Title or Test Link column in Source list (lets say you select the Value A), the script does not fire at all, if i hover over the hyperlink, the who hyperlink is shown and does not open the hyperlink in the modal pop up.
    - This is important because i want to be able to sort on a particular item...
    Could someone please let me know what am i doing wrong and why is this not working when i sort the list. Thanks for all the help.
    Once again i am trying to open a sharepoint list item in Sharepoint 2013 from another list using Jquery

    A ListItem has its own unique row id so in all likelihood, an insert with the same data will result in a new list entry. The Lists Web Service however, has an UpdateListItem method which will take an update request. [refer
    http://msdn.microsoft.com/en-us/library/office/websvclists.lists.updatelistitems(v=office.15).aspx ]
    There is another note in the conference (marked answered) to your List Item Update problem. Probably worth a try too. [refer
    http://social.msdn.microsoft.com/Forums/en-US/bee8f6c6-3259-4764-bafa-6689f5fd6ec9/how-to-update-an-existing-item-in-a-sharepoint-list-using-the-wss-adapter-for-biztalk?forum=biztalkgeneral ]
    Regards.

  • Filter list items based on security groups o365

    How to filter list items based on security groups in o365.

    Hi,
    According to your description, my understanding is that you want to filter list items based on the Office 365 security groups.
    If that is the case, I suggest you can create a data view to filter the list items with CAML Query like below:
    <Where>
    <Membership Type="CurrentUserGroups">
    <FieldRef Name="VisibleToGroup"/>
    </Membership>
    </Where>
    For more information, please refer the detailed article below:
    SharePoint - Filtering a View by Group Membership
    Thanks
    Best Regards
    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]

  • CAML query performance for large lists

    I have a list with more than 10000 items. I am retrieving the items and displaying it in a RAD Grid on my page using CAML query. While retrieving the items, around 1000 records are retrieved due to filter. I have enabled paging in my grid and PageSize is
    set to 25. I have noticed that the load time of my page is very slow as it retrieves all the 1000 records at once.
    Is it possible to retrieve just 25 records for the first page on load. On click on the Next button or Page number it should retrieve the next set of 25 records for that particular page.
    I want to know if there is any way to link CAMl query paging with RAD grid paging
    Any code example would be greatly helpful.

    Hi,
    For pagination in SPListItem use the SPQuery.ListItemCollectionPosition property. 
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquery.listitemcollectionposition(v=office.15).aspx
    check the usefull urls
    http://omourad.blogspot.in/2009/07/paging-with-listitemcollectionposition.html
    http://www.anmolrehan-sharepointconsultant.com/2011/10/client-object-model-access-large-lists.html
    Anil

  • "SharePoint list itme update error : Invalid data has been used to update the list item. The field you are trying to update may be read only."

    Hi Everyone,
    i am facing one problem ...
    when i am updating an SharePoint List item, it is throwing above error....
    This is my code......
     try
                    tbl = getListDateTable("NCR");
                    DataTable dt = tbl;
                    oWebsite = mysite.OpenWeb();
                    oList = oWebsite.Lists["NCR"];
                    SPListItem itemToUpdate = null;
                    foreach (SPListItem listItem in oList.Items)
                        listItem.Update();
                        workOrderID = Convert.ToInt32(txtTitle.Text);
                        itemToUpdate = listItem;
                    //SPListItem itemToUpdate = oList.GetItemById(workOrderID);
                    //itemToUpdate.Fields["Title"].ReadOnlyField = false;
                    //string str = ddlStatus.SelectedValue;
                    itemToUpdate["Title"] = txtTitle.Text;
                    itemToUpdate["JobNumber"] = txtJobNumber.Text;
                    itemToUpdate["PartNumber"] = txtPartNumber.Text;
                    itemToUpdate["PartDescription"] = txtPartDescription.Text;
                    //itemToUpdate["RequiredBy"] = txtRequiredBy.Text;
                    itemToUpdate["ReportedBy"] = txtReportedBy.Text;
                    itemToUpdate["WrittenBy"] = txtWrittenBy.Text;
                    //itemToUpdate["DateOpened"] = txtDateOpened.SelectedDate;
                    //itemToUpdate["DateClosed"] = txtDateClosed.SelectedDate;
                    itemToUpdate.Update();
                    oList.Update();
                   // bind();
                catch (Exception ex)
                    throw ex;
    Thanks
    viswanath

    Hi Viswanath,
    If you are using People/User Type Field Column then use below code methord
    SPUser user = web.EnsureUser(loginName);
    item["UserTypeFieldName"] = user;
    Lookup Type Field Column then use below code methord
    public static SPFieldLookupValue GetLookupFieldFromValue(string lookupValue,string lookupSourceColumn, SPList lookupSourceList)
    SPFieldLookupValue value = null;
    SPQuery query = new SPQuery();
    query.Query = "<Where><Eq><FieldRef Name='" + lookupSourceColumn + "'/><Value Type='Text'>" + lookupValue + "</Value></Eq></Where>";
    SPListItemCollection listItems = lookupSourceList.GetItems(query);
    if(listItems.Count > 0 )
    value = new SPFieldLookupValue(listItems[0].ID,lookupValue);
    return value;
    item["LookupField"] = GetLookupFieldFromValue(lookupfieldValue, lookupSourceColumn, listName);
    Please mark the replies as answers if they help or unmark if not.

  • Sharepoint List Retention Policy based on Modified Date

    How do I implement a Sharepoint List Retention Policy that deletes list items that haven't been modified in X days?
    I've tried to create a retention policy in Sharepoint, but I only get the option to base the policy on:
    Created Date
    Declared Record
    I need the policy to be based on Modified Date, a standard date field that appears against all lists & document libraries. Is there a configuration change I can make to cause Modified Date to appear in the list of available fields on the Retention Policy
    dialog window?
    Thanks.

    Veda, thanks but I'm not really a hardcore C# coder.
    We found more elegant solution was to create a List View which returns all records that should be deleted, based on our own custom deletion criteria, and then create an very simple SSIS Package in Visual Studio using the
    Sharepoint Connectors for SSIS to delete all Sharepoint List Items returned from that List View. The Sharepoint Destination Connector has a delete operation.
    This worked for us and didn't require any coding.

  • Populate the values  to  list item based on a check box

    Hi,
    How can i populate the values from a field on the form to one list item based on a check box,
    the pseudo code is like,
    if checkbox = checked then
    populate the particular field value to the list item;
    checkbox = unchecked;
    next_record;
    end if;
    Thanks
    Bcj

    To populate a Tlist item, do the following:
    1. Create a TLIST item in the EMP block. and give it a height to accommodate several names.
    2. Using the TLIST property pallete:
    a. Set the Column Name property to EMPNO
    b. Click on the Elements in List property. Delete each List Element and delete each List Item Value. If you don't do this you will get an error when you compile.
    3. Create a record group using this query:
    select ename, to_char(empno) from emp
    4. Create a WHEN-NEW-FORM-INSTANCE trigger, and place this code inside the trigger:
    Declare
    err_num number;
    Begin
    clear_list('YOUR_TLIST');
    err_num := populate_group('YOUR_RECORD_GROUP');
    If err_num = 0 Then
    populate_list('YOUR_TLIST', 'YOUR_RECORD_GROUP');
    Else
    message('Error populating Tlist');
    message('Error populating Tlist');
    End If;
    End;
    5. Compile and run the form. The ENAMEs will appear in the TList, and each ENAME will have a value equal to its EMPNO.

  • Report workload by calculating how many versions of SharePoint list items created in a certain time period

    I have a total of 66 SharePoint 2010 lists - yes, 66! - each lists contains between 1500 and 3200 list items.  My employees update these various list items throughout their workday.  Each update to a list item creates a new version of the list
    item.  On average each list item will have anywhere from 5 to 10 versions before it is done.  I need to create a report that tells me how many list items they've updated in a certain time frame.  I have come close but still cannot arrive at
    the data I'm looking for. 
    This is what I have so far:
    I've created a report using SQL Report Builder 2008 v3 where I've filtered it to show only items MODIFIED between, for example, Feb1 and Feb28.  Of those records, I want the report to tell me how many versions were created during that time
    frame.  The result is one list item with 5 total versions.  Versions 1.0, 2.0, & 3.0 were created on 12/12/14.  The last two versions, 4.0 and 5.0, were created on 2/24/15.  Therefore, the answer I'm looking for is 2 because they
    created 2 versions between Feb1 and Feb28.
    However I get the following results using these queries:
    If I do a =Sum(Fields!owshiddenversion.Value) in the expression field I get the total versions which is 5
    If I do a =Count(Fields!owshiddenversion.Value) in the expression field I get the instance which is 1
    Is there a way to count ONLY the number of versions created in a time period?  Is there another hidden field in SharePoint that I can use in the expression that will give me results I'm looking for?

    Hi Rafael70,
    Per my understanding that you have already get all the need fields and informaiton of the updated version of list items and now you want to calculate how many versions of SharePoint list items created in a certain time period, you can't get desired result
    using sum and count function, right?
    I have tried to tested on my local environment but because I am not clear what is value in the field "owshiddenversion", I assumed you have two datatype parameters (StartDate and EndDate) to help filter the report in a certain time period.
    Generally, if you have add the filter correctly, it will filter the correct number's updated version in this time period, I would like you to provide details information as below to help better analysis the requirements:
    Could you please provide sample data of the table.
    Please provide snapshot of the report structure you have currently designed.
    Please try to provide all the expression you have used.
    If you still have any problem, please feel free to ask.
    Regards,
    Vicky Liu
    Vicky Liu
    TechNet Community Support

  • Uploading multiple documents into sharepoint list item with REST in sharepoint 2013 using content editor web part :

    hi ,
    i am trying to upload multiple document files into sharepoint list item. I followed below link for implementaion.
    http://techfindings-prem.blogspot.in/search/label/jquery.multifilejs
    It was working for sharepoint hosted app.
     This complete code is written within content edito web part.
    It was working when i was in root site collection with below change (hard coded the root level url) in code in "UploadFile" function.
    var scriptbase = "http://servername" + "/_layouts/15/";
                console.log(' File size:' + bytes.length);
                $.getScript(scriptbase + "SP.RequestExecutor.js", function () {
                    var createitem = new SP.RequestExecutor("http://servername");
                    createitem.executeAsync({
                        url: "http://servername/sites/cpg/" + "/_api/web/lists/GetByTitle('SalesRecord')/items(" + attachmentitemid + ")/AttachmentFiles/add(FileName='"
    + fileName + "')",
                        method: "POST",
                        binaryStringRequestBody: true,
                        body: binary,
                        success: fsucc,
                        error: ferr,
                        state: "Update"
                    function fsucc(data) {
                        //alert( data.statusText + "\n\n" + data.responseText);
                        console.log(data + ' uploaded successfully');
                        deferred.resolve(data);
                    function ferr(data) {
                        //alert( data.statusText + "\n\n" + data.responseText);
                        console.log(fileName + "not uploaded error");
                        deferred.reject(data);
    But the issue came in picture when i was working with the other site collection instead of root one. The url was like below.
    "http://servername/sites/cpg/". This time i need to be there within "cpg" site collection. 
    Now if i hard code the url as i did above my code gets break here while come to below line
     $.getScript(scriptbase + "SP.RequestExecutor.js", function () {
    I am getting error when i used below code:
    var scriptbase = "http://servername" + "/_layouts/15/";
     $.getScript(scriptbase + "SP.RequestExecutor.js", function () {
                    var createitem = new SP.RequestExecutor("http://servername");
                    createitem.executeAsync({
                        url: "http://servername/sites/cpg/" + "/_api/web/lists/GetByTitle('SalesRecord')/items(" + attachmentitemid + ")/AttachmentFiles/add(FileName='"
    + fileName + "')",
                        method: "POST",
                        binaryStringRequestBody: true,
                        body: binary,
                        success: fsucc,
                        error: ferr,
                        state: "Update"
                    function fsucc(data) {
                        //alert( data.statusText + "\n\n" + data.responseText);
                        console.log(data + ' uploaded successfully');
                        deferred.resolve(data);
                    function ferr(data) {
                        //alert( data.statusText + "\n\n" + data.responseText);
                        console.log(fileName + "not uploaded error");
                        deferred.reject(data);
    Please hekp in this case. This complete code is written within content edito web part. 
    Regards:
    Sanjay Joshi

    Hi,
    According to your post, my understanding is that you have an issue about upload multiple documents files into library vai REST API.
    As you have said, you have used the hard code url in your code.
    How about use the _spPageContextInfo.webAbsoluteUrl method to get the url?
    I have used this method to get the url, then use the code in the article you have pasted within a content editor web part to upload the files.
    You can replace the hard code url with the _spPageContextInfo.webAbsoluteUrl method, then check whether it works.
    Thanks,
    Jason
    Jason Guo
    TechNet Community Support

  • Workflow to grant access to each List item based on a column value

    Hi,
    I have 2 lists Risks and RisksLookup.
    In Risks, I have Title, Description, service impacted and status columns.
    In RisksLookup, I have service impacted, AD1, AD2, AD3, AD4 and AD5.
    I have a requirement where in I have to write a Workflow to provide access to each List item based on the value of service impacted. i.e. If service impacted in Risks List is Client A, I have to lookup what all AD groups are present for Client A in RisksLookup
    List and provide access to only those groups for that item.
    Regards, Shreyas R S

    Hi
    another approach
    create 5 more lists, dedicated to each impacted service. for  Each one these lists apply needeed right ( based onAD groups )Keep you main list where first level will add new items . Attach a workflow to this main list, which will start when an item
    is added and which will add specific item's value to his new list ( based on impacted service value )
    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

  • How to fetch the Attched Filname of SharePoint List Item

    Hi All,
    Is there a way to fetch name of the file attached to the sharepoint list item ? Basically what we need is the file name which user has uploaded while submitting the new item, Later the same list item will get edited with another file attachment.
    We want to compare both these file names and set a Image status value which will be a dropdown. When a new item is created Status will be 'Submitted' after editing the same list item its status should become 'Resubmitted' only if attached file name is dfferent.
    We tried in SP designer 2010, but CurrentItem:Attachments is giving option either Yes or No. and from javascript we are able to retrieve filename attched but when stored it to another list column for comparison, the filename is stored as 1 which is a boolean
    value
    Please suggest us on how this can be done.
    Thanks,
    Raghu

    Hi Raghu,
    Did you the OOB Custom List? What't the error when you follow the steps from the above aritcle?
    I have ever tested a
    case to show attachment url in the Issue Tracking list, you can check if the following code could work for you.
    <xsl:element name="SharePoint:AttachmentsField">
    <xsl:attribute name="runat">server</xsl:attribute>
    <xsl:attribute name="FieldName">Attachments</xsl:attribute>
    <xsl:attribute name="Visible">true</xsl:attribute>
    <xsl:attribute name="ControlMode">Display</xsl:attribute>
    <xsl:attribute name="ItemId">
    <xsl:value-of select="$thisNode/@ID"/>
    </xsl:attribute>
    </xsl:element>
    Thanks
    Daniel Yang
    TechNet Community Support

  • Link to Sharepoint List Item

    I have a report that I built in SQL Report Builder 3.0 that pulls data from a SharePoint 2013 list. The fields are data, location, cost, department, and reference. The reference field is number that is input by the user on the SharePoint 2013 list. Is
    there a way for the reference field in the report to be a direct link back to open the SharePoint list item when it is clicked in the report?

    Hi,
    According to the description, I know you want to redirect to the SharePoint site by clicking on the value in the reference field in your report. Take the steps below to achieve this:
    1. Right-click reference field > Text box Properties in the designer surface.
    2. Click on Action page, check the option of Go to URL.
    3. In the Select URL box, type the URL of your SharePoint list.
    e.g. http://TestServer/toplevelsite/subsite/Lists/<Listname>/AllItems.aspx
    4. Click ok. Save and upload the report.
    This URL redirects to the SharePoint list page. If you want to redirect to the display form page of an item,
     use the code like:
    ="javascript:void(window.open('http://servername/sites/xx/Lists/listname/DispForm.aspx?ID=" & Fields!ID.Value & "&Title= "& Fields!Title.Value &"'))"
    ID and Title are used to identify the item which redirect to. You can change it according to the columns.                                                                                                                                                                                          
    Thanks.
    Tracy Cai
    TechNet Community Support

  • How to insert sharepoint list item attachment to sql server db programatically

    Hi,
    I need to insert sharepoint list item attachments to sql server db programatically. Could some one suggest some approach and if any one work on it please provide the code. Thanks in advance

    hi,
    you can do it using powershell. Use the below script to loop through all the items attachments inside list.
    $web = $site.RootWeb<br />
    $Lists = $Web.Lists[$ListName]
    $Library = $web.Lists[$LibName]
    foreach($listItem in $Lists.Items)
    if($listItem.Attachments.Count -gt 0)
    Write-Host "**************************************************"
    Write-Host $listItem.Attachments.Count"Attachment(s) available in the ListItem:" $listItem.Title
    Write-Host "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
    $i=0
    foreach($attachment in $listItem.Attachments)<br />
    $i++
    Write-Host $i".Attachment Name:" $listItem.Attachments.UrlPrefix$attachment
    $file = $web.GetFile($listItem.Attachments.UrlPrefix+$attachment)
    Write-Host "Adding Files to Library:"$Library.Title
    $bytes = $file.OpenBinary()
    Write-Host "Successfully Added"<br /> Write-Host "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
    Write-Host "**************************************************"
    And use the below script to insert into SQL.
    #Connect to DB
    $DB = “server=MyInstanceName;integrated security=sspi;database=Bob”
    $conn = new-object System.Data.SqlClient.SqlConnection($DB)
    #Build the command and parameters
    $cmd = New-Object System.Data.SQLClient.SQLCommand
    $cmd.CommandType = [System.Data.CommandType]‘StoredProcedure‘
    $cmd.Parameters.Add(“@Col1″, [System.Data.SqlDbType]‘VarBinary‘)
    $cmd.Parameters[“@Col1″].Size = -1
    $cmd.Parameters[“@Col1″].Value = $bytes
    $sql = "INSERT INTO <table> (Col1) VALUES " + $cmd.Parameters[“@Col1″]
    #Execute the command
    $conn.Open()
    $cmd.ExecuteNonQuery()
    P.S. There may be some syntax error you have to make it work but the concept is right.
    Whenever you see a reply and if you think is helpful,Vote As Helpful! And whenever you see a reply being an answer to the question of the thread, click Mark As Answer

Maybe you are looking for

  • Mail downloads emails over and over agin

    I have used Mail for years and as always worked fine but a couple of weeks ago after some updates this append! In my Mail app, i am having a problem with receiving "duplicate" emails. i will get an email, and after in downloads to Mail, the "spinning

  • Creative MediaSource File Convers

    I just bought a Zen Micro and I have a question about transfering mp3's using creative media source. I only want to upload 28kbs songs onto my micro to maximize the number of songs and reduce battery consumption. At the moment I'm using a third party

  • Variable with proposed value in BEX Query View

    Dear SAP-Gurus, I have a Web Application with some views on one query. In the inital screen i show the popup for entering the global variable values. Now my question; is it possible to give a global variable used filled by exit and used in these quer

  • There was a yahoo plugin but i cannot remove this because i see it not in my search what can i do?

    I installed a programm and there was probilly the plugin from yahoo. But this plugin i cannot find on my computer.

  • Is it possible to save the login for Lightroom Mobile?

    Every time I close out Lightroom, I have to sign back into Mobile at the top.  Is there not a way to save or remember the log in so it automatically logs in when I start LR?  If not, how about a feature request? Thanks! Kevin McIntyre