Aktualisiere die README.md mit Anweisungen zur Registrierung des Field Customizers und Command Sets; füge neue Parameter für Command Set IDs in Enable- und Disable-ExpiryIndicator.ps1 hinzu; erstelle Test-ExpiryIndicatorRegistration.ps1 zur Überprüfung der Registrierung.
This commit is contained in:
@@ -9,7 +9,9 @@ param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$ExpiryFieldInternalName,
|
||||
|
||||
[Guid]$FieldCustomizerComponentId = 'a555f4fc-d6a6-4421-8189-457449d9bbde'
|
||||
[Guid]$FieldCustomizerComponentId = 'a555f4fc-d6a6-4421-8189-457449d9bbde',
|
||||
|
||||
[Guid]$CommandSetComponentId = 'cd58f5d9-ffc8-4df7-a910-3054842d7abf'
|
||||
)
|
||||
|
||||
$isapiPath = Join-Path ([Environment]::GetFolderPath('CommonProgramFiles')) 'microsoft shared\Web Server Extensions\16\ISAPI'
|
||||
@@ -22,22 +24,42 @@ $context.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
|
||||
try {
|
||||
$list = $context.Web.Lists.GetByTitle($ListTitle)
|
||||
$field = $list.Fields.GetByInternalNameOrTitle($ExpiryFieldInternalName)
|
||||
$customActions = $list.UserCustomActions
|
||||
$context.Load($list)
|
||||
$context.Load($field)
|
||||
$context.Load($customActions)
|
||||
$context.ExecuteQuery()
|
||||
|
||||
if ($field.InternalName -ne $ExpiryFieldInternalName) {
|
||||
Write-Warning "Das Feld wurde über seinen Anzeigenamen gefunden. Für eine stabile Konfiguration sollte der interne Name '$($field.InternalName)' verwendet werden."
|
||||
Write-Warning "Das Feld wurde über seinen Anzeigenamen gefunden. Verwende künftig den internen Namen '$($field.InternalName)'."
|
||||
}
|
||||
|
||||
$field.ClientSideComponentId = $FieldCustomizerComponentId
|
||||
$field.ClientSideComponentProperties = '{}'
|
||||
$field.Update()
|
||||
|
||||
$commandAction = $customActions | Where-Object {
|
||||
$_.Name -eq 'ExpiryIndicator.CommandSet' -or
|
||||
$_.ClientSideComponentId -eq $CommandSetComponentId
|
||||
} | Select-Object -First 1
|
||||
|
||||
if ($null -eq $commandAction) {
|
||||
$commandAction = $customActions.Add()
|
||||
}
|
||||
|
||||
$commandAction.Name = 'ExpiryIndicator.CommandSet'
|
||||
$commandAction.Title = 'ExpiryIndicator commands'
|
||||
$commandAction.Location = 'ClientSideExtension.ListViewCommandSet.CommandBar'
|
||||
$commandAction.ClientSideComponentId = $CommandSetComponentId
|
||||
$commandAction.ClientSideComponentProperties = '{}'
|
||||
$commandAction.Update()
|
||||
|
||||
$context.ExecuteQuery()
|
||||
|
||||
Write-Host "ExpiryIndicator wurde für '$($list.Title)' an '$($field.InternalName)' gebunden."
|
||||
Write-Host "Field Customizer wurde an '$($field.InternalName)' gebunden."
|
||||
Write-Host "Command Set wurde an '$($list.Title)' registriert."
|
||||
Write-Host 'Bitte die moderne Listenansicht mit Strg+F5 neu laden.'
|
||||
}
|
||||
finally {
|
||||
$context.Dispose()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user