תשובה How to retrive the deleted data through code based on time and date in sharepoint

  • יום חמישי 09 אוגוסט 2012 13:38
     
     

    Hello All,

     Please let me know if there is any link or if you can directly provide me the code for the below problem:-

     How to retrive the deleted data based on time and date in sharepoint through code ?

    Thanks and regards,

    Sushil Sahu


    sushil sahu

כל התגובות

  • יום חמישי 09 אוגוסט 2012 20:46
     
     
    You can use SPList.GetChanges on all lists to get changes pertaining to Delete action. By default, the change log retention period is 60 days.
  • יום שישי 10 אוגוסט 2012 07:38
     
     

    Hello Guru, 

    As i have to retrive the deleted data based on time and date in sharepoint through code so from where should i retrieve it ?

    1) from the recycle bin or

    2) from the logs ?

    and if i have to retrieve it from the log then where should i find the log of the deleted data in sharepoint?

    what should be the query in these cases?

    Thanks and regards,

    Sushil Sahu


    sushil sahu

  • יום שישי 10 אוגוסט 2012 09:45
     
     

    Hello All,

     Can anybody please reply to the above queries ?

    thanks and  regards,

    sushil sahu


    sushil sahu

  • יום שישי 10 אוגוסט 2012 10:15
    מנחה דיון
     
     הצעה לתשובה

    Hi ,

    You can retrieve the data from Change Log. The change log is not a flat file stored somewhere on the file system, nor is it actually a single log. Every content database contains an EventCache table that is the “change log” for objects contained in the database. Each row in the table is an entry in the log. Columns in the table contain information such as the date and time of a change, the type of object that was changed, the nature of the change, and a unique identifier for the object.

    You can refer to example code here to get the deleted items as Guru suggested :

    SPList.GetChanges Method (SPChangeQuery): http://msdn.microsoft.com/en-us/library/ms439213.aspx

    Overview of the Change Log: http://msdn.microsoft.com/en-us/library/bb417456.aspx

    Thanks,

    Entan Ming


    Entan Ming

    TechNet Community Support

  • יום שישי 10 אוגוסט 2012 10:34
     
     

    Thanks Guru and Entan,

     So can i retrieve the deleted data directly querying on the EventCache table in the Content Database and restore it to its previsous place from where i had deleted it means in the list ?

    thanks and regards,

    sushil sahu


    sushil sahu

  • יום שישי 10 אוגוסט 2012 11:13
    מנחה דיון
     
     

    Hi ,

    You can refer  to this site for more information about save and restore the change token :

    How to: Save and Restore a Change Token: http://msdn.microsoft.com/en-us/library/ff408387   

    Thanks,

    Entan Ming


    Entan Ming

    TechNet Community Support

  • יום שישי 10 אוגוסט 2012 13:27
     
     

    Thanks Entan,

     Can you let me know that, what should be the query for retrieving the data from the change logs and restoring it to the lists again ?

    thanks,

    Sushil Sahu


    sushil sahu

  • יום שישי 10 אוגוסט 2012 21:29
     
     הצעה לתשובה

    If you are looking at restoring the actual content which was deleted from the site, you can go to Recycle Bin and look for the deleted content. The retention period for first stage Recycle Bin is 30 days and second stage Recycle Bin is 50 days.

    http://office.microsoft.com/en-us/sharepoint-server-help/restore-a-deleted-object-from-a-sharepoint-recycle-bin-HA102655219.aspx?CTT=1

  • יום שני 13 אוגוסט 2012 03:53
     
     

    Thank you Guru and Entan for the nice information you gave me,

    and yes i want to restore the actual content which was deleted from the lists of the site , i can restore them from the recycle bin directly without any code but is there any way that i can restore the data from the recycle bin itself but using few lines of code because i have to do it using the code ...?

    Or can i retrieve the deleted data directly from the change log of the content database using some code, so that i can restore them back to the lists from where i had deleted the data ...?

    Please let me know the way..

    Thanks,

    Sushil Sahu


    sushil sahu

  • יום שני 13 אוגוסט 2012 09:55
     
     

    Hello All,

    As Entan replied that, "You can retrieve the data from Change Log. The change log is not a flat file stored somewhere on the file system, nor is it actually a single log. Every content database contains an EventCache table that is the “change log” for objects contained in the database. Each row in the table is an entry in the log. Columns in the table contain information such as the date and time of a change, the type of object that was changed, the nature of the change, and a unique identifier for the object."

    So is there actual data also exists in the change log..?

    And if not then please let me know , what are the possible places from where i can fetch the deleted data using the code ?

    Thanks and regards,

    Sushil


    sushil sahu

  • יום שני 13 אוגוסט 2012 20:29
     
     

    EventCache table only contains the metadata of changes and not the actual content delta (binary for docs and xml for list items) which was added/updated/deleted.

    http://msdn.microsoft.com/en-us/library/bb417456.aspx

  • יום שלישי 14 אוגוסט 2012 07:29
     
     

    Thanks Guru,

    So can i retrieve the actual content of the deleted list from the recycle bin or completed deleted list from the recycle bin using code in javascript..?

    Please let me know.

    Thanks,

    Sushil Sahu


    sushil sahu

  • יום שלישי 14 אוגוסט 2012 07:36
     
     

    Or suggest me something from where i can retrieve or restore back the deleted data of list using some code in javascript...

    Thanks,

    Sushil


    sushil sahu

  • יום שלישי 14 אוגוסט 2012 13:53
     
     

    Hello All,

    Please let me know about, restoring the data from sharepoint recycle bin using javascript code ?

    Means i have to restore back the data from sharepoint recycle bin which i had deleted from any list of sharepoint , but i have to do it through using javascript code?

    Thanks,

    Sushil Sahu 


    sushil sahu

  • יום חמישי 16 אוגוסט 2012 04:44
     
     

    Thank you All,

    But please let me know the javascript code using which i can restore the deleted data from the recycle bin which i had deleted from any list..?

    Thanks,

    Sushil Sahu


    sushil sahu

  • יום שישי 17 אוגוסט 2012 03:18
    מנחה דיון
     
     תשובה

    Hi ,

    As far as I know, only site collection administrators can access all the items in the recycle bin. So you cannot use javascript to restore all the items from recycle bin. You can use SharePoint Object Model to access the site recycle bin and restore the items. Below is a sample code:

    SPSecurity.RunWithElevatedPrivileges(delegate()

    {

      using (SPSite site = new SPSite("http://server/"))

      {

        using (SPWeb web = site.OpenWeb())

        {

          if (web.RecycleBin.Count > 0)

          {

            web.RecycleBin[0].Restore();

          }

        }

      }

    });

    For more information ,please refer to these sites:

    how to restore items from recycle bin sharepoint programmatically?: http://stackoverflow.com/questions/4095884/how-to-restore-items-from-recycle-bin-sharepoint-programmatically

    Programmatically Manage SharePoint Recycle Bin: http://keremozen.com/2011/12/26/programmatically-manage-sharepoint-recycle-bin/

    Thanks,

    Entan Ming


    Entan Ming

    TechNet Community Support

    • סומן כתשובה על-ידי sushil sahu יום חמישי 30 אוגוסט 2012 12:40
    •  
  • יום שישי 17 אוגוסט 2012 04:59
     
     

    Thanks Entan,

    In recycle bin there is a column named "Original Location" it contains the path of the items from where they got deleted , so i think i can i restore them back to there original place.

    But the code you have suggested does not contain any parameter for PATH where the items are to be restored ?

    So can it be done using the PATH and is it there in the Restore method ?

    Please let me know ...

    Thanks,

    Sushil Sahu


    sushil sahu

  • יום שלישי 21 אוגוסט 2012 06:43
     
     

    Hello All,

    I have written following suggested code (in one of the posts) in my javascript file(Delrestore.js) the code is :-

    var Restore ={

         

    DelRestore:function()
    {
       $(document).ready(function () { ExecuteOrDelayUntilScriptLoaded(loadConstants, "sp.js"); });   
       function loadConstants()
       {   
        var ctx = new SP.ClientContext.get_current();   
        var site = ctx.get_site(); 
        IPC_siteUrl = site.get_url(); 
        IPC_siteId = site.get_id();   
        var web = ctx.get_web();  
        web.RecycleBin.Restore();
       }
    }
                     } And i have called this code on click of a button of one of my .aspx page. But i am getting this error :- "

    <dir>

    The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

    </dir>

    sp.runtime.js?rev=9sKdsC9N6p2BiRk3313M7Q%3D%3D, line 2 character 19964"  Please let me know the solution.                                                                                                                       Thanks and regards,                                                                                                                    Sushil Sahu


    sushil sahu


    • נערך על-ידי sushil sahu יום שלישי 21 אוגוסט 2012 06:43
    •  
  • יום שלישי 21 אוגוסט 2012 06:45
     
     

    I dont know what happed the query i wrote above is not having proper alignment , because my enter button was not working on the microsoft forum posts console.

    Thanks,

    Sushil


    sushil sahu

  • יום שלישי 21 אוגוסט 2012 09:56
     
     תשובה

    Can anyboday please reply to the above quesries ?

    i have also tried with the below code: -

    function DelRestore()
    {

    $(document).ready(function () {
       var site=$().SPServices.SPGetCurrentSite();
       var context = new SP.ClientContext.get_current();
       var web = context.get_web();
       alert("sushil");
       web.RecycleBin.Restore();

    }

    }

    But the above code is giving an error such as "'_spBodyOnLoadFunctionNames' is undefined". and also "Restore property or method is not supported"

    i have also tried the below code :-

    function DelRestore()
    {
       var site=$().SPServices.SPGetCurrentSite();
       var context = new SP.ClientContext.get_current();
       var web = context.get_web();
       web.RecycleBin.Restore();        
    }                                                                                                                                                            Please let me know the solution.                                                                                                           Thanks,

    Sushil Sahu


    sushil sahu

    • סומן כתשובה על-ידי sushil sahu יום חמישי 30 אוגוסט 2012 12:39
    •