0

I made REST API call to recycle the item, which works successfully:

var requestDigestValue = $("#__REQUESTDIGEST").val();

if (requestDigestValue) {
  $.ajax({
    type: "POST",
    url:
      _spPageContextInfo.webAbsoluteUrl +
      "/_api/web/lists/getByTitle('ListName')/items(" +
      baseEngine.Id +
      ")/recycle()",
    headers: {
      accept: "application/json; odata=verbose",
      "IF-MATCH": "*",
      "X-RequestDigest": requestDigestValue.toString(),
    },
    success: function (data) {
      window.location.reload();
    },
    error: function (error) {
      console.log(error);
    },
  });
}

But in Recycle Bin, item deleted doesn't show any name, but ID which isn't of any help:

recycle bin

How to get name/title or any property of item instead of ID information?

2 Answers 2

0

To get the name/title of the deleted item in the Recycle Bin using REST API, you can modify the URL to include the $select parameter with the desired properties.

Here's an example of the modified code:

var requestDigestValue = $("#__REQUESTDIGEST").val();

if (requestDigestValue) {

  $.ajax({
    type: "POST",
    url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('ListName')/items(" + baseEngine.Id + ")/recycle()?$select=Title",
    headers: {
      "accept": "application/json; odata=verbose",
      "IF-MATCH": "*",
      "X-RequestDigest": requestDigestValue.toString()
    },
    success: function(data){
      window.location.reload();
    },
    error: function(error){
      console.log(error);
    }
  });
}
0

I doubt that is because of your code.

The Recycle Bin shows the default Title field value for regular list items, and the file Name field value for documents.

If the list is configured so that the default Title field is not required (maybe hidden?) and the list items don't have a Title value, then only the ID will show in the Recycle Bin.

If you really need to see text values in the Recycle Bin, there are a couple things you could do:

  • If your list has a text field that you use as a primary identifier, but you just didn't want it to be named "Title", you can just rename the default Title field's display name to be what you want, and use that instead of the other field (maybe even remove the other field). Keep in mind that if this list already has a bunch of data in it then you would need to copy over the values from that other text field into the Title field before you remove the old field or you will lose all those item's "titles".
  • If you really need to keep the Title field hidden, you could use a workflow to copy some text into the Title field on item creation (also maybe on update, if that makes sense) so that there is something to see in the Recycle Bin. For instance, if your primary field is a user field, you could copy the user's display name into the Title field. In any case, you would set that up knowing that whatever goes into the Title field is primarily there for you to see in the Recycle Bin. (But keep in mind that any data in the Title field may also affect search results.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.