SitecorePowerShell / Console

Sitecore PowerShell Extensions
https://doc.sitecorepowershell.com/
Other
114 stars 70 forks source link

Content Editor:Ribbon - Scripts do not have access to the Selected Item from content Editor #464

Closed jasonchester closed 9 years ago

jasonchester commented 9 years ago

Forgive me if I am missing something but when launching a script from the content editor ribbon i would expect to have access to the item selected in the content editor.

Example Ribbon Script:

"input: " + $input
"input[0]: " + $input[0]
dir variable:

URL captured in Browser Missing Id:

http://.../sitecore/shell/default.aspx?xmlcontrol=PowerShellRunner&id&db&lang&ver&scriptId=%7BDF525740-8A1A-455F-871A-A7B857E2789E%7D&scriptDb=master

Script Output where PWD is C:\windows\system32\inetsrv:

input:
input[0]:

Name                           Value
----                           -----
$
?                              True
^
AppPath                        C:\inetpub\wwwroot\chescore8.local\Website\
AppVPath                       /
args                           {}
ClientData                     Sitecore.Data.SqlServer.SqlServerClientDataStore
ClientPage                     ASP.sitecore_shell_default_aspx
ConfirmPreference              High
ConsoleFileName
DebugPreference                SilentlyContinue
Error                          {}
ErrorActionPreference          Continue
ErrorView                      NormalView
ExecutionContext               System.Management.Automation.EngineIntrinsics
false                          False
FormatEnumerationLimit         4
HOME
Host                           System.Management.Automation.Internal.Host.InternalHost
HostSettings                   Cognifide.PowerShell.Core.Settings.ApplicationSettings
HttpContext                    System.Web.HttpContext
input                          System.Collections.ArrayList+ArrayListEnumeratorSimple
MaximumAliasCount              4096
MaximumDriveCount              4096
MaximumErrorCount              256
MaximumFunctionCount           4096
MaximumHistoryCount            4096
MaximumVariableCount           4096
me                             sitecore\admin
MyInvocation                   System.Management.Automation.InvocationInfo
NestedPromptLevel              0
null
OutputEncoding                 System.Text.ASCIIEncoding
PID                            7828
ProgressPreference             Continue
PSBoundParameters              {}
PSCommandPath                  master:\system\Modules\PowerShell\Script Library\Secure Campaign\Content Editor\Ribbo...
PSCulture                      en-US
PSDefaultParameterValues       {}
PSEmailServer
PSHOME                         C:\Windows\System32\WindowsPowerShell\v1.0
PSScript                       Sitecore.Data.Items.Item
PSScriptRoot                   master:\system\Modules\PowerShell\Script Library\Secure Campaign\Content Editor\Ribbo...
PSSessionApplicationName       wsman
PSSessionConfigurationName     http://schemas.microsoft.com/powershell/Microsoft.PowerShell
PSSessionOption                System.Management.Automation.Remoting.PSSessionOption
PSUICulture                    en-US
PSVersionTable                 {PSVersion, WSManStackVersion, SerializationVersion, CLRVersion...}
PWD                            C:\windows\system32\inetsrv
request                        System.Web.HttpRequest
response                       System.Web.HttpResponse
ScriptSession                  Cognifide.PowerShell.Core.Host.ScriptSession
ShellId                        Microsoft.PowerShell
SitecoreContextItem
SitecoreDataFolder             C:\inetpub\wwwroot\chescore8.local\Data
SitecoreDebugFolder            C:\inetpub\wwwroot\chescore8.local\Data/debug
SitecoreIndexFolder            C:\inetpub\wwwroot\chescore8.local\Data/indexes
SitecoreLayoutFolder           C:\inetpub\wwwroot\chescore8.local\Website\layouts
SitecoreLogFolder              C:\inetpub\wwwroot\chescore8.local\Data/logs
SitecoreMediaFolder            C:\inetpub\wwwroot\chescore8.local\Website\upload
SitecorePackageFolder          C:\inetpub\wwwroot\chescore8.local\Data/packages
SitecoreSerializationFolder    C:\inetpub\wwwroot\chescore8.local\Data/serialization
SitecoreTempFolder             /temp
SitecoreVersion                8.0.150427
StackTrace
tempPath                       C:\Windows\TEMP
tmpPath                        C:\Windows\TEMP
true                           True
VerbosePreference              SilentlyContinue
WarningPreference              Continue
WhatIfPreference               False
AdamNaj commented 9 years ago

Hi Jason,

You have indeed found a bug in the ribbon synchronization script that got exposed due to how Sitecore 8 changed its controls naming. I believe this worked in Sitecore 7 fine when button id's were named differently. Thank you for reporting that!

If you can open the following script: /sitecore/system/Modules/PowerShell/Script Library/Platform/Internal/Integrations/Content Editor Ribbon

And change the line 60 from:

$button.Click = "item:executescript(id=`$Target,script=$($script.ID),scriptDb=$($script.Database.Name))"

to

$button.Click = "item:executescript(id=`$ItemID,script=$($script.ID),scriptDb=$($script.Database.Name))"

Changing the token from $Target to $ItemID and synchroniza the integration points again this should start working.

AdamNaj commented 9 years ago

Fixed.