4

I have an SPE script which content team runs from the script context menu. The script deletes the current context item. Once the item is deleted, and I close the script pop-up. I get another pop-up saying the selected item could not be found. enter image description here

Is there a way to select another item (parent item in my case) in the tree node after the item is deleted so that this warning message can be avoided.

Also, is there a way to refresh the content tree from the selected node from SPE?

1 Answer 1

5

Navigating in Content Editor is not really what Sitecore Powershell Extension is built for. But it's possible to run javascript from SPE that will do the redirect for you:

$id = $deletedItem.Parent.ID.ToString()
$script = ('window.top.location = "/sitecore/shell/Applications/Content%20Editor?fo=' + $id +'"')
Invoke-JavaScript -Script $script

Be aware that if you add this at the end of your SPE script, it will not show message saying that script execution is completed and will redirect immediately to the parent item.

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.