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")
$eventReceivers = $srcList.EventReceivers
$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=, Culture=neutral, PublicKeyToken=71e9bce111e9429c";
$ERDCI.EventType = [Microsoft.SharePoint.Client.EventReceiverType]::ItemAdding
$ERDCI.Synchronization = [Microsoft.SharePoint.Client.EventReceiverSynchronization]::Synchronous
$receiver = $eventReceivers.Add($ERDCI);
$ERDCI.EventType = [Microsoft.SharePoint.Client.EventReceiverType]::ItemAdding

Event is ItemAdded not ItemAdding.

other than that, it should work

  • Thanx Tiago !!! – oysterhoys May 28 '18 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.