【问题标题】:Sharepoint online powershell usercustomactions scriptblock not workingSharepoint在线powershell用户自定义操作脚本块不起作用
【发布时间】:2020-11-24 07:57:26
【问题描述】:

我想在 SP 在线站点的顶部添加一条警告消息。为此,我使用 powershell 尝试了 UserCustomActions,代码运行没有错误但无法正常工作。我尝试添加正在工作的功能区控件。我在管理站点中启用了允许脚本选项。下面我包含了供参考的代码。

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")

Function Add-ScriptLinkAction([Microsoft.SharePoint.Client.ClientContext]$Context,[String]$ScriptBlock,[int]$Sequence)
{

    $action = $Context.Site.UserCustomActions.Add();
    $action.Location = "ScriptLink"
    <#
    if($ScriptSrc) {
        $action.ScriptSrc = $ScriptSrc
    }#>
    
    if($ScriptBlock) {
        $action.ScriptBlock = $ScriptBlock
    }
    $action.Sequence = $Sequence
    $action.Name = "title"
    $action.Title = "title"
    $action.Update()
    $Context.ExecuteQuery()
}

$siteUrl = 'https://stginfotechchennai.sharepoint.com/sites/ProductQualityReseachCenter'
$context = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
# SPO credentials
$context.Credentials = Get-SPOCredentials -UserName username@domain.com

Add-ScriptLinkAction -Context $context -ScriptBlock $ScriptBlock -Sequence 1000 

【问题讨论】:

    标签: powershell sharepoint sharepoint-online csom


    【解决方案1】:

    @Hemanth 库马尔,

    SharePoint 在线现代 UI 不支持 scriptlink 用户自定义操作、工具栏项 (CommandUI.Ribbon) 和自定义菜单项 (EditControlBlock) 仍受支持。更多详情,您可以参考:

    根据文档建议,您可能需要转向 SPFx 扩展:

    BR

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-31
      • 1970-01-01
      相关资源
      最近更新 更多