Hi ,
I am trying to delete AEM page programmatically using pagemanager.delete() OFTB
method but for some pages I am facing an exception it states - Error while deleting page & other exception was Error while creating a version. Does anyone has any idea when does these 2 exception comes
Note: page that I want to delete is not having any children
Thanks,
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Nimma05
These exceptions suggests that exceptions you’re encountering when using PageManager.delete() in AEM are related to issues with the page’s versioning, permissions ensure that the page is not involved in any active workflows. Workflow references can sometimes prevent page deletion.
what you can try to skip versioning while deleting a page like
PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
Page page = pageManager.getPage("/content/my-site/page-to-delete");boolean skipVersioning = true;
pageManager.delete(page, skipVersioning);
also check if the page has a corrupt version history you can remove older versions if needed
Hi @Nimma05 , Please check below to investigate it.
Try with pageManager.delete(pageManager.getPage(pagePath), true) and see if it works.
For the further investigation.
1- Check if the Page is being used by another process (workflow etc.)
2- If the page has multiple versions or is part of a version history, deleting the current version might not be sufficient. You might need to delete all versions or handle versioning.
3- Double-check that the user or service running the deletion code has the required access rights.
Otherwise, for testing, try deleting the page manually in the AEM. This may provide more detailed error messages or pop-ups that can give more clues about the failure
Hi @Nimma05
These exceptions suggests that exceptions you’re encountering when using PageManager.delete() in AEM are related to issues with the page’s versioning, permissions ensure that the page is not involved in any active workflows. Workflow references can sometimes prevent page deletion.
what you can try to skip versioning while deleting a page like
PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
Page page = pageManager.getPage("/content/my-site/page-to-delete");boolean skipVersioning = true;
pageManager.delete(page, skipVersioning);
also check if the page has a corrupt version history you can remove older versions if needed
Can you please share the relevant parts of the exceptions?
@Nimma05 Did you find the suggestion helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies