1. I think you are using the correct function. Might be you have also deleted the parent page to the one you are trying to restore
2. Might be a bug. Try first sending items to wastebasket and then delete them? To get all events triggered...
When I try to move items to waste basket using MoveToWastebasket method, I get an exception saying that Delete permission is required when a scheduled job is run automatically. At the same time it works ok if I start the job manually. How do I get it work for a scheduled job?
When running automatically you run as anonymous user that lacks those access rights.
1. Create a new system user that has delete access rights at least.
2. Run scheduled job as that user
PrincipalInfo.CurrentPrincipal = PrincipalInfo.CreatePrincipal("your.username");
However, after I used these functions, the full text search index started to act abnormally, new content cannot be indexed and the reindex function doesn't work anymore.
This could be because the content you're deleting is referenced on some other content. When this other content would be indexed it would crash the indexing because one of it's references is missing.
Normally when you remove a page from the UI you get a prompt like this:
So through there this isn't necessarily an issue, but programatically it doesn't prompt. It just deletes the content.
You can solve this if you run
var referencesToPage = ContentRepository.GetReferencesToContent(pageToRemove.ContentLink, true/false); // last parameter can be true if you want to get content that references any of the "pageToRemove"s children as well.
before deleting you can see how that content is referenced, then you could delete the references based on the data you get out of that method call.
Hope this helps!
However, after I used these functions, the full text search index started to act abnormally, new content cannot be indexed and the reindex function doesn't work anymore.
This could be because the content you're deleting is referenced on some other content. When this other content would be indexed it would crash the indexing because one of it's references is missing.
Normally when you remove a page from the UI you get a prompt like this:
So through there this isn't necessarily an issue, but programatically it doesn't prompt. It just deletes the content.
You can solve this if you run
var referencesToPage = ContentRepository.GetReferencesToContent(pageToRemove.ContentLink, true/false); // last parameter can be true if you want to get content that references any of the "pageToRemove"s children as well.
before deleting you can see how that content is referenced, then you could delete the references based on the data you get out of that method call.
Hope this helps!
This could be because the content you're deleting is referenced on some other content. When this other content would be indexed it would crash the indexing because one of it's references is missing.
Normally when you remove a page from the UI you get a prompt like this:
So through there this isn't necessarily an issue, but programatically it doesn't prompt. It just deletes the content.
You can solve this if you call this method before deleting:
var referencesToPage = ContentRepository.GetReferencesToContent(pageToRemove.ContentLink, true/false); // last parameter can be true if you want to get content that references any of the "pageToRemove"s children as well.
From there you can see how that content is referenced, then you could delete the references based on the data you get out of that method call.
Hope this helps!
Question 1: move content to waste basket
I tested IContentRepository.MoveToWastebasket() funtion, but when I tried to restore the content from the recycle bin, it showed: "The original place for the content does not exist. Where would you like to restore the content?" and ask me to choose a location to restore the content to.
However this doesn't satisfy the demand, the content are moved to waste basket in batches, and some of them might need to be restored to it's original place. Is there a better way to move content to recycle bin prgrammatically?
Question 2: delete content
I also need to delete content progammatically, the functions I use is IContentRepository.Delete() and IContentRepository.DeleteChildren(). However, after I used these functions, the full text search index started to act abnormally, new content cannot be indexed and the reindex function doesn't work anymore.
I am using EPiServer 8.11.0, is there a better API I should use here?