Provison Column Defaults with PowerShell/SCOM
-
17-01-2021 - |
سؤال
I found several post on how to add a custom LocationBasedDefaults file in the forms folder to provision Column Defaults in a SharePoint List: First and Second
These were based on CSOM/#C I was able to translate these to CSOM/PowerShell, and successfully add the custom column values to lists. Except for the final step witch is to register an event receiver that uses the custom file. Any help translating that code would be very welcome:
This PowerShell I tried, gives no errors, but is not giving results either:
$srcList = $Web.Lists.GetByTitle("MyList")
$ctx.load($srcList)
$ctx.executeQuery()
$eventReceivers = $srcList.EventReceivers
$ctx.Load($eventReceivers)
$ctx.ExecuteQuery()
$ERDCI = New-Object Microsoft.SharePoint.Client.EventReceiverDefinitionCreationInformation
$ERDCI.ReceiverName = "LocationBasedMetadataDefaultsReceiver ItemAdded";
$ERDCI.SequenceNumber = 1000;
$ERDCI.ReceiverClass = "Microsoft.Office.DocumentManagement.LocationBasedMetadataDefaultsReceiver";
$ERDCI.ReceiverAssembly = "Microsoft.Office.DocumentManagement, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c";
$ERDCI.EventType = [Microsoft.SharePoint.Client.EventReceiverType]::ItemAdding
$ERDCI.Synchronization = [Microsoft.SharePoint.Client.EventReceiverSynchronization]::Synchronous
$receiver = $eventReceivers.Add($ERDCI);
$ctx.Load($receiver);
$ctx.ExecuteQuery();
المحلول
$ERDCI.EventType = [Microsoft.SharePoint.Client.EventReceiverType]::ItemAdding
Event is ItemAdded
not ItemAdding
.
other than that, it should work
لا تنتمي إلى sharepoint.stackexchange