3

I have a custom list inside our SharePoint online and it contain many items.

Now I want to add some business logic to the list through implementing a remote event receiver which get fired when items are been created and edited. but I am not sure how can I attach a remote event receiver to existing list?

Last time I did so was around 3 years ago, where I followed the steps mentioned on this link and they worked well for me @ Attaching Remote Event Receivers to Lists in the Host Web.

But recently when i tried this appraoch, I got an error related to the fact that azure service bus (which will be used to debug the RER) has been retired and can not used any more to debug remote event receivers.

Now I found this link Remote Event Receivers Creating and Debugging in SharePoint Online, but it does not show how to attach the remote event receiver to existing list, as in this link they added a new list as part of the remote event receiver project.

So can anyone help me in finding a full documentation on "how we can create and debug a remote event receiver and attach it to existing list in sharepoint online?" and can I use a mix between the approaches mentioned on the above 2 links? attach RER to existing list and use Azure powershell to create the service bus?

Thanks

1

Here is the code for attaching an 'ItemAdded' event receiver with CSOM:

var serviceUrl = "https://remote-event-receiver-service-url";

var list = clientContext.Web.Lists.GetByTitle("TestList1");

var eventReceiverInfo = new EventReceiverDefinitionCreationInformation
{
    EventType = EventReceiverType.ItemAdded,
    Synchronization = EventReceiverSynchronization.Asynchronous,
    ReceiverName = "MyTestEventReceiver",
    ReceiverUrl = serviceUrl,
    SequenceNumber = 10000
};

list.EventReceivers.Add(eventReceiverInfo);
clientContext.ExecuteQuery();

You can debug your web service with the help of ngrok. It forwards requests to a public endpoint to localhost.

  • thanks a lot for the reply. is there a full documentation about this? – SharePoint TestDev Aug 6 at 1:10
  • 1
    I'd recommend reading the following post demonstrating adding/removing event receivers for lists: sharepointnutsandbolts.com/2014/01/… But you're right - not so much info about this since MS recommends using web hooks instead: docs.microsoft.com/en-us/sharepoint/dev/apis/webhooks/… – Dmitry Kozlov Aug 6 at 6:17
  • web hooks will not work for me, as it does not support actions such as itemadding, itemupdating, etc.. – SharePoint TestDev Aug 8 at 1:12
  • 1
    That's right, but from my experience those synchronous events are not totally reliable. We encountered the situations when synchronous event receivers were not working for days. Finally, we reconsidered the architecture of our solution and migrated to web hooks. – Dmitry Kozlov Aug 8 at 8:11
  • 1
    In your case, I'd consider implementing a kind of permissions management system - provide users with permissions to corresponding items depending on certain conditions either in web hooks or recurring jobs/flows. – Dmitry Kozlov Aug 9 at 15:20

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.