API for looking at documents-Pages in the Recycle Bin

David Pearson asked on September 30, 2016 20:03

Problem:

Fact 1: I have a page (custom page type) that has been sent to the recycle bin with a redirect to search our products page.

Fact 2: I have some news articles that could link to pages (aka product page/custom page type) that are in the recycle bin that will land on the redirect page Search Our Product when the product is the recycle bin

Looking for this end result: When a site visitors arrives on a page of a discontinue product I would like to be able to search the recycle bin for the discontinue product specs then display similar products with the same specs on the search page.

Question? Is the Recycle bin just a bit in the GetDocument object? Can I query the recycle bin using DocumentHelper.GetDocumentsā€¦.

Recent Answers


Trevor Fayas answered on September 30, 2016 21:10

Everything exists in the database at a bare minimum, and I believe the 'history' is in the CMS_VersionHistory table.

There is also an API VersionHistory classes. You should be able to find it in there, otherwise check CMS_VersionHistory for the 'VersionDeletedWhen' (VersionDeletedWhen is not null).

However the relationship between a deleted version and deleted document i'm unsure (not sure if you can have a deleted version of a document while having another verion live).

0 votesVote for this answer Mark as a Correct answer

Richard Sustek answered on October 3, 2016 08:44

This code will get you data set of all pages that are stored in Recycle bin. In your case it might make sense to cache e.g. the List of DocumentIDs of pages in a recycle bin for a quick access to data and to avoid executing unnecessary queries each time a user goes to old page.

private DataSet GetRecycleBinPages()
{
    int topN = -1; // all pages

    return VersionHistoryInfoProvider.GetRecycleBin(SiteContext.CurrentSiteID, 0, null, null, topN, null, DateTimeHelper.ZERO_TIME, DateTimeHelper.ZERO_TIME);
}
2 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.