I've been doing a lot more SPE report implementations and noticed that the functionality of loading the ListView is dependent on whether the editor is using the Content Editor from Launchpad or the Content Editor from the Desktop.

Initial Configuration:

  • Script calls Show-ListView without -Modal parameter
  • Script calls Close-Window after calling Show-ListView

Desktop -> Content Editor
The ListView window will open once the Running Script window finishes. This adds another tab to the Sitecore task bar as expected.

Launchpad -> Content Editor
The Running Script window stays open and the ListView never opens.

It turns out that the Close-Window call seems to be closing the actual ListView in the second scenario. Removing the Close-Window call, however, requires the user to actually click close on the Running Script window. A minor inconvenience.

I also tried the -Modal route, which works fine in conjunction with Close-Window and loads the ListView just fine, however, in the first scenario, Desktop -> Content Editor, when opening an item in the ListView, the Content Editor window which opens with that item, loads behind the modal and the editor is forced to close the ListView modal in order to interact with it.

So my question is: Is there a native way to determine whether an editor is in the Desktop -> Content Editor versus the Launchpad -> Content Editor?

No, there is no native way to determine it.

Ohter approach

You might want to play with Invoke-JavaScript cmldet to solve your problem.

You could execute JS code to determine your current location (window.location.href):

  • http://domain/sitecore/shell/default.aspx - DesktopCE
  • http://domain/sitecore/shell/Applications/Content%20Editor.aspx?sc_bw=1 - LaunchpadCE

the problem is that it is hard to return this value back to PowerShell script.

If your only problem is to close particular window you might want to skip two-way communication and just do things on front-end side.

Example:

Invoke-JavaScript -Script 'setTimeout(function(){console.log("auto window close");window.parent.document.querySelector(".ui-dialog .ui-icon-closethick").click();},1000)'

enter image description here

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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