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:
@@ -209,8 +209,8 @@ Nach **Speichern** wird die Konfiguration pro Liste beziehungsweise Bibliothek i
|
|||||||
|
|
||||||
### Anzeige aktivieren
|
### Anzeige aktivieren
|
||||||
|
|
||||||
Die Einstellungen registrieren noch nicht den Field Customizer an der kundenspezifischen Ablaufdatumsspalte.
|
Der Field Customizer und das Command Set werden einmal pro Liste beziehungsweise Bibliothek mit dem
|
||||||
Diese Zuordnung erfolgt einmal pro Feld mit dem mitgelieferten Skript:
|
mitgelieferten Skript registriert:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
.\scripts\Enable-ExpiryIndicator.ps1 `
|
.\scripts\Enable-ExpiryIndicator.ps1 `
|
||||||
@@ -220,7 +220,8 @@ Diese Zuordnung erfolgt einmal pro Feld mit dem mitgelieferten Skript:
|
|||||||
```
|
```
|
||||||
|
|
||||||
Der Wert von `ExpiryFieldInternalName` muss mit **Internes Ablaufdatumsfeld** in den Einstellungen
|
Der Wert von `ExpiryFieldInternalName` muss mit **Internes Ablaufdatumsfeld** in den Einstellungen
|
||||||
übereinstimmen. Danach die Listenansicht neu laden.
|
übereinstimmen. Das Skript registriert zugleich die Befehle **Expiry-Einstellungen** und
|
||||||
|
**Ablaufdatum +1 Jahr**. Danach die Listenansicht neu laden.
|
||||||
|
|
||||||
### Ablaufdatum um ein Jahr verlängern
|
### Ablaufdatum um ein Jahr verlängern
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ param(
|
|||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$ExpiryFieldInternalName,
|
[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'
|
$isapiPath = Join-Path ([Environment]::GetFolderPath('CommonProgramFiles')) 'microsoft shared\Web Server Extensions\16\ISAPI'
|
||||||
@@ -22,23 +24,30 @@ $context.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
|
|||||||
try {
|
try {
|
||||||
$list = $context.Web.Lists.GetByTitle($ListTitle)
|
$list = $context.Web.Lists.GetByTitle($ListTitle)
|
||||||
$field = $list.Fields.GetByInternalNameOrTitle($ExpiryFieldInternalName)
|
$field = $list.Fields.GetByInternalNameOrTitle($ExpiryFieldInternalName)
|
||||||
|
$customActions = $list.UserCustomActions
|
||||||
$context.Load($list)
|
$context.Load($list)
|
||||||
$context.Load($field)
|
$context.Load($field)
|
||||||
|
$context.Load($customActions)
|
||||||
$context.ExecuteQuery()
|
$context.ExecuteQuery()
|
||||||
|
|
||||||
if ($field.ClientSideComponentId -ne $FieldCustomizerComponentId) {
|
if ($PSCmdlet.ShouldProcess("$($list.Title)/$($field.InternalName)", 'ExpiryIndicator-Registrierungen entfernen')) {
|
||||||
throw "Das Feld '$($field.InternalName)' ist nicht mit dem erwarteten ExpiryIndicator-Field-Customizer verbunden."
|
if ($field.ClientSideComponentId -eq $FieldCustomizerComponentId) {
|
||||||
}
|
|
||||||
|
|
||||||
if ($PSCmdlet.ShouldProcess("$($list.Title)/$($field.InternalName)", 'Field-Customizer-Verknüpfung entfernen')) {
|
|
||||||
$field.ClientSideComponentId = [Guid]::Empty
|
$field.ClientSideComponentId = [Guid]::Empty
|
||||||
$field.ClientSideComponentProperties = ''
|
$field.ClientSideComponentProperties = ''
|
||||||
$field.Update()
|
$field.Update()
|
||||||
|
}
|
||||||
|
|
||||||
|
$customActions | Where-Object {
|
||||||
|
$_.Name -eq 'ExpiryIndicator.CommandSet' -or
|
||||||
|
$_.ClientSideComponentId -eq $CommandSetComponentId
|
||||||
|
} | ForEach-Object {
|
||||||
|
$_.DeleteObject()
|
||||||
|
}
|
||||||
|
|
||||||
$context.ExecuteQuery()
|
$context.ExecuteQuery()
|
||||||
Write-Host "ExpiryIndicator-Verknüpfung wurde entfernt. Feld und Daten bleiben unverändert."
|
Write-Host 'ExpiryIndicator-Registrierungen wurden entfernt. Feld und Daten bleiben unverändert.'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
$context.Dispose()
|
$context.Dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ param(
|
|||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$ExpiryFieldInternalName,
|
[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'
|
$isapiPath = Join-Path ([Environment]::GetFolderPath('CommonProgramFiles')) 'microsoft shared\Web Server Extensions\16\ISAPI'
|
||||||
@@ -22,22 +24,42 @@ $context.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
|
|||||||
try {
|
try {
|
||||||
$list = $context.Web.Lists.GetByTitle($ListTitle)
|
$list = $context.Web.Lists.GetByTitle($ListTitle)
|
||||||
$field = $list.Fields.GetByInternalNameOrTitle($ExpiryFieldInternalName)
|
$field = $list.Fields.GetByInternalNameOrTitle($ExpiryFieldInternalName)
|
||||||
|
$customActions = $list.UserCustomActions
|
||||||
$context.Load($list)
|
$context.Load($list)
|
||||||
$context.Load($field)
|
$context.Load($field)
|
||||||
|
$context.Load($customActions)
|
||||||
$context.ExecuteQuery()
|
$context.ExecuteQuery()
|
||||||
|
|
||||||
if ($field.InternalName -ne $ExpiryFieldInternalName) {
|
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.ClientSideComponentId = $FieldCustomizerComponentId
|
||||||
$field.ClientSideComponentProperties = '{}'
|
$field.ClientSideComponentProperties = '{}'
|
||||||
$field.Update()
|
$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()
|
$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 {
|
finally {
|
||||||
$context.Dispose()
|
$context.Dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
50
scripts/Test-ExpiryIndicatorRegistration.ps1
Normal file
50
scripts/Test-ExpiryIndicatorRegistration.ps1
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$SiteUrl,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$ListTitle,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$ExpiryFieldInternalName
|
||||||
|
)
|
||||||
|
|
||||||
|
$isapiPath = Join-Path ([Environment]::GetFolderPath('CommonProgramFiles')) 'microsoft shared\Web Server Extensions\16\ISAPI'
|
||||||
|
Add-Type -Path (Join-Path $isapiPath 'Microsoft.SharePoint.Client.Runtime.dll')
|
||||||
|
Add-Type -Path (Join-Path $isapiPath 'Microsoft.SharePoint.Client.dll')
|
||||||
|
|
||||||
|
$context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
|
||||||
|
$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()
|
||||||
|
|
||||||
|
Write-Host "Liste: $($list.Title)"
|
||||||
|
Write-Host "Feld: $($field.InternalName)"
|
||||||
|
Write-Host "Field Customizer: $($field.ClientSideComponentId)"
|
||||||
|
Write-Host ''
|
||||||
|
Write-Host 'List User Custom Actions:'
|
||||||
|
|
||||||
|
$actions = @($customActions | Where-Object {
|
||||||
|
$_.Location -like 'ClientSideExtension.ListViewCommandSet*' -or
|
||||||
|
$_.Name -like 'ExpiryIndicator*'
|
||||||
|
})
|
||||||
|
|
||||||
|
if ($actions.Count -eq 0) {
|
||||||
|
Write-Warning 'Kein ExpiryIndicator Command Set an der Liste registriert.'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$actions | Select-Object Name, Title, Location, ClientSideComponentId, ClientSideComponentProperties |
|
||||||
|
Format-List
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
$context.Dispose()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user