I added a button option along with edithtml

enter image description here

on the click, I am calling and executing the powershell


I am not able to get the context item inside the powershell script.

However, if I execute the powershell script on click on any button in ribbon, I do get the context item.

Any idea why it is happening? and how can i get the context or current item on button click of richtext field


1 Answer 1


You can try something like this:

Step 1: Modify the Button Command to Pass the Item ID When defining your button command, you need to pass the current item's ID as a parameter to the PowerShell script. You can do this by modifying the command configuration.

Step 2: Retrieve the Item ID in Your PowerShell Script In your PowerShell script, retrieve the item ID from the parameters and then use that ID to get the context item.

Here’s an example PowerShell script that demonstrates how to do this:


Retrieve the item using the item ID passed as a parameter

$currentItem = Get-Item -Path "master:/sitecore/content//*[@@id='{0}' -f $itemid]"

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.