1

I added a button option along with edithtml

enter image description here

on the click, I am calling and executing the powershell

item:executescript(id=$Target,script={ACD773A7-93DC-49A8-8497-73CEEC9C5A9E},scriptDb=master)

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

2

1 Answer 1

2

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:

powershell

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.