2

I'm trying to add an html link to each row containing a reference to an arbitrary item. Essentially I want to load a custom item, but it not be the same item as the record.

I tested with both scForm.postRequest and scForm.postEvent but could not get it working. What I have below does not appear to have any response when clicking the link.

As you can see below, the record is "Sample Item 1" but the link points to the "Home" item.

Example Report

Here is the script I'm working with:

# Sample Item 1
$root = Get-Item -Path "master:" -ID "{C89D37FF-3919-4D69-9925-943B67BD22D6}"

$items = @($root)
# Home
$id = "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}"

$items |
    Show-ListView -Property Name,
        @{Label="ArbitraryItem"; Expression={ 
            "<a href='#' onclick=`"javascript: scForm.postRequest('','','','item:open(id=$id)')`">Show me Home</a>" 
        }}
Close-Window

What is the proper syntax?

3

This should do the job:

scForm.showModalDialog('/sitecore/shell/Applications/Content-Editor?id=$id&amp;vs=1&amp;la=en&amp;fo=$id&amp;sc_content=master&amp;mo=popup', '_blank', 'getBestDialogSize:true;header:Content Editor');
$items |
    Show-ListView -Property Name,
        @{Label="ArbitraryItem"; Expression={ 
            "<a href='#' onclick=`"javascript: scForm.showModalDialog('/sitecore/shell/Applications/Content-Editor?id=$id&amp;vs=1&amp;la=en&amp;fo=$id&amp;sc_content=master&amp;mo=popup', '_blank', 'getBestDialogSize:true;header:Content Editor');`">Show me Home</a>" 
        }}
Close-Window

How did I get this?

To get this I opened chrome dev tools and observed network tab.

Your expected behavior happens when you double-click on a ListView item. There will be 3 requests, one of them with __PARAMETERS:OnDoubleClick.

Inspect this request and see the response from the server. I obtained json with 3 commands. The one that is interesting for us is the second one (Eval command). Inside you will see the js code I pasted at the beginning of my answer ;) (Additionally I replaced hardcoded ID with $id variable)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.