4

Is there a way to query items in the Recycle bin by their ID? I'm trying to recover a deleted page and retrieved the page itself, but it has many datasource items which also need to be recovered. Looking at presentation details (of the restored item) shows GUIDs where the datasource items are missing. When I try to search using a GUID in the recycle bin I can't enter a search term over 20 characters so cannot enter a GUID. Is there some hack to get around this, or would I need to write my own admin page to do this?

2

From what I can see there is no option to search in Recycle Bin (or any other Sitecore archive) by item id.

Even if you use Chrome dev tools (or similar in other browser) to change the max length of the field, it won't work with item id. If you check the request which is sent to the server, you will see it's like:

FILTER (Name LIKE '%KEYWORD%') OR (OriginalLocation LIKE '%KEYWORD%') OR (ArchivedBy LIKE '%KEYWORD%');

It looks like there is even some option for SQL injection maybe.

So it looks like custom admin page would be needed. But if you look at Sitecore.Data.Archiving.SqlArchive class, it looks like methods to find and restore items using item id may be there and simple code should be enough:

public Guid GetArchivalId(ID itemId)
public bool RestoreItem(Guid archivalId)
3
  • 2
    Even if you use Chrome dev tools (or similar in other browser) to change the max length of the field, it won't work with item id haha I tried this myself also and no luck. – Matthew Dresser Feb 12 '18 at 19:55
  • Would make for an interesting SPE command. – Michael West Feb 13 '18 at 1:26
  • I just opened a feature request with Sitecore on this. I agree that it would be handy. – Aren Cambre Feb 21 '20 at 19:35
0

It is possible by updating Sitecore's standard files.

Edit below file, and add one more entry inside node <Columns runat="server">

sitecore\shell\Applications\Archives\RecycleBin\RecycleBin.xaml.xml

<GridColumn DataField="ItemId" Visible="true" SortedDataCellCssClass="SortedDataCell" runat="server" IsSearchable="true"/>

Now edit below js file

sitecore\shell\Applications\Archives\RecycleBin\RecycleBin.js

And update below method, it will increase the char limit to 260

setInterval(function () {
    var searchBox = document.querySelector("[id$=searchBox]");
    if (jQuery(searchBox).attr("maxlength") == 20) {
        jQuery(searchBox).attr("maxlength", 260);
    }
    if (searchBox && searchBox.value.indexOf('\"') != -1) {
        searchBox.value = searchBox.value.replace(/"/g, "");
    }; }, 50);

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.