Programmatically how to get the Max Item ID or Max Created Datetime of SharePoint Custom List items?

Answered Programmatically how to get the Max Item ID or Max Created Datetime of SharePoint Custom List items?

  • Freitag, 22. Juni 2012 04:33
     
     
    Programmatically how to get the Max Item ID or Max Created Datetime of SharePoint Custom List items?

    Amalaraja Fernando,
    SharePoint Architect
    Please Mark As Answer if my post solves your problem or Vote As Helpful if a post has been helpful for you. This post is provided "AS IS" with no warrenties and confers no rights.


Alle Antworten

  • Freitag, 22. Juni 2012 05:15
     
     

    1) Using Data View Web Part (SharePoint Designer). Sort the list in descending order of Item ID and set page size to 1, it will return single record with the highest ID.

    Same for the Created Date time.

    2) Using ECMAScript. Write the code to fetch list order by Item ID in descending order.


    Thanks, Neha Navale

  • Freitag, 22. Juni 2012 05:43
     
     Beantwortet

    Thanks Neha for the reply. We would like to programmatically achieve this in a Windows Application.

    We are planning to perform this activity using CAML query with the below logic

    1. Get the list items in descending order
    2. Set row limit as one and retrive the record

    CAML Query:

    <View><Query><OrderBy><FieldRef Name='ID' Ascending='False'/></OrderBy>
          <Where> <Eq> <FieldRef Name='Title' /> <Value Type='Text'></Value> </Eq> </Where> </Query>
          <RowLimit>1</RowLimit>
    </View>

    Reference link: http://msdn.microsoft.com/en-us/library/ee534956.aspx


    Amalaraja Fernando,
    SharePoint Architect
    Please Mark As Answer if my post solves your problem or Vote As Helpful if a post has been helpful for you. This post is provided "AS IS" with no warrenties and confers no rights.


  • Samstag, 23. Juni 2012 09:21
     
     

    hi,

    how to get the 

    Max Created time 

    and how check the time to current time 


    Maanik

  • Montag, 25. Juni 2012 05:57
     
     
    I think you have to change created date type to date and time and use the same CAML query.

    Amalaraja Fernando,
    SharePoint Architect
    Please Mark As Answer if my post solves your problem or Vote As Helpful if a post has been helpful for you. This post is provided "AS IS" with no warrenties and confers no rights.

  • Montag, 25. Juni 2012 10:53
     
     

    hi,

    no i didn't change created date type 

    i have one time job its run every one hour 

    the timer job hit the list ever one hour.

    my problem i want to check the last item created time and current time compare two time. if item created 9am to 10am no mail send other wise mail send a person this job going on every one hour (i want code of the logic)

    would u please give me the clear coding for me its very use for me 


    Maanik