I am trying to develop an add-in for SharePoint Online that ensures all document libraries created get my company's base content type and the standard document content type gets removed.

I have the ListAdded remote event receiver working to do this task. I also have a WebProvisioned event receiver that will attach the listAdded event receiver to new sub-sites.

This now kinda works, however when the add-in gets removed it only removes the event receivers from the top level site and the event receivers in sub-sites get orphaned and can't be deleted. How can I loop through the sub-sites in the appuninstalling event?

I'd like to avoid having to install the add-in to every subsite.


1 Answer 1


Figured my problem out. I needed to be adding the remote event receiver at the site collection level and not the web level, which I didn't think was possible with CSOM.

So I needed using this PNP example solution as a base, I needed to change cc.Web.EventReceivers to cc.Site.EventReceivers and also make sure the Addin had the correct access to the site collection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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