5

In SPE I need to create a report where each record has a link. When the link is clicked additional parameters are provided to the second report.

How would I go about creating such a report?

1 Answer 1

7

I noticed while reviewing the official SPE docs that it's possible to add custom links into the report.

Start by creating a script module containing your primary and secondary reports.

First Example

Contents of Second Report

Get-Item -Path "master:" -ID $parameter1 | Select-Object -Property * | Show-ListView -Property Name, ID, ItemPath

Contents of First Report

Import-Function Render-ReportField
Close-Window

$script = Get-Item -Path "master:" -ID "{6BC2FA09-3733-4B3F-9D6C-6F7FA8EE20D7}"

$props = @{
    Property = @(
        "Name",
        "ID"
        @{Label="More"; Expression={ Render-ScriptInvoker $script @{parameter1=$_.ID;} "Run Second Report" }.GetNewClosure() }
    )
    InfoTitle = "Report Reporter"
    InfoDescription = "More details"
}

Get-ChildItem -Path "master:\content\home" -WithParent | Show-ListView @props

Notes:

  • The first report uses Render-ScriptInvoker to execute another script.
  • The expression takes the script item, parameters made available in the script, and the display text.
  • The use of GetNewClosure() is so that we can leverage $_ in the hashtable used for splatting with Show-ListView.
  • Not sure why, but using Show-ListView in the second report script required me to use explicit property names rather than relying on the default values or using *. SPE must be reusing a list of property names.

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.