Unable to attach remote eventreceiver on list

Highlighted
Deleted
Not applicable

We create a remote event receiver. and in the install of the app it attaches to every List with a specific contenttype. 

Now the client wants a new list which we add with PNP. we had to write a extention provider to attach the event receiver to the list. Till here all looks fine when we look at it with the SharePoint Client Browser  it seems attached, and exact the same as the existing lists with one difference.

 

the eventreceiver does not trigger. this is the code we use:

Snippet

context.Load(spList.EventReceivers);
           context.ExecuteQuery();
           var hasAddedItemReceiver =
               spList.EventReceivers.FirstOrDefault(e => e.ReceiverName == eventreceiver.addedreceivername);
           if (hasAddedItemReceiver == null)
           {
               Trace.TraceInformation(
                   $"RER - CreateProjectDocumentSetReceivers - {eventreceiver.eventreceivertype} - {spList.Title}");
 
               try
               {
                   var receiver = new EventReceiverDefinitionCreationInformation();
                   switch (eventreceiver.eventreceivertype)
                   {
                       case "ItemAdded":
                           receiver = new EventReceiverDefinitionCreationInformation
                           {
                               EventType = EventReceiverType.ItemAdded
                           };
                           break;
                       case "ItemUpdated":
                           receiver = new EventReceiverDefinitionCreationInformation
                           {
                               EventType = EventReceiverType.ItemUpdated
                           };
                           break;
                       case "ItemDeleting":
                           receiver = new EventReceiverDefinitionCreationInformation
                           {
                               EventType = EventReceiverType.ItemDeleting
                           };
                           break;
 
 
                   }
 
 
                   // Get WCF URL where this message was handled
                   receiver.ReceiverUrl = eventreceiver.eventurl;
                   receiver.ReceiverName = eventreceiver.addedreceivername;
                   receiver.Synchronization = EventReceiverSynchronization.Synchronous;
 
                   // Add the new event receiver to a list in the host web
                   spList.EventReceivers.Add(receiver);
                   context.ExecuteQuery();
               }
               catch (Exception ex)
               {
                   Trace.TraceError("RER - CreateProjectDocumentSetReceivers: " + ex.Message);
               }
           }

Maybe we are missing something some help would be nice thanks in advance. 

0 Replies