【问题标题】:Sitecore PowerShell wait for Show-ListView modal to close before proceedingSitecore PowerShell 等待 Show-ListView 模式关闭,然后再继续
【发布时间】:2021-12-10 15:44:16
【问题描述】:

我正在编写一个脚本,用于删除自用户提供的日期以来未登录的用户。

我想做以下事情:

  1. 从用户那里获取日期。 (这里没问题)
  2. 获取用户列表。 (这里没问题)
  3. 向用户展示可能受影响的用户的 ListView。 (这里没问题)
  4. 等待模式窗口关闭后再继续(这是我卡住的地方)
  5. 做一些其他的事情...

步骤 1-3 工作正常,但是当模态窗口弹出时,之后的所有代码都会立即执行,而模型窗口仍然打开。

我认为 Wait-ScriptSession 可能是我的答案,但它并没有起到作用。这是我现在拥有的(伪代码)

#gather users, etc
Start-ScriptSession -ScriptBlock {$listOfRemovedUsers | Show-ListView @outputProps -Property $columns} -Id "Removable Users Modal" -Interactive
Wait-ScriptSession -Id "Removable Users Modal" -Timeout 30
#do some more stuff

【问题讨论】:

标签: powershell sitecore


【解决方案1】:

在运行 Show-ListView 后,使用如下所示的确认对话框,而不是使用 Wait-ScriptSession

 $listOfRemovedUsers | Show-ListView @outputProps -Property $columns
 Show-Confirm -Title "Do you want to proceed"
    

然后您会看到一个弹出窗口,询问您是否要继续。与此同时,脚本执行将被阻止,直到您单击“确定”或“取消”

【讨论】:

    【解决方案2】:

    我也遇到过类似的情况。我找到的唯一解决方案是使用“-modal”参数:https://doc.sitecorepowershell.com/appendix/common/show-listview#modal-less-than-switchparameter-greater-than

    类似这样的:

    $listOfRemovedUsers | Show-ListView -Modal
    $response = Show-Confirm -Title "Do you want to proceed?"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-19
      • 2013-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多