0

I have downloaded the PnP sample project ECM.AutoTagging and have configured an azure service bus for debugging, have created new client id/token and updated the app manifest/web.config and so on. I can set breakpoints on library creation and the code to attach the event receiver is run. I check with PnP PowerShell that is has been added also:

$list = Get-PnPList -Identity AutoTaggingSampleItemAdded
Get-PnPEventReceiver -List $list

ReceiverName                                             ReceiverId                           SequenceNumber EventType
------------                                             ----------                           -------------- ---------
PnPAutoTaggingItemAdded                                  b599481b-76e8-4159-8a82-a59b5b8f0f18 0              ItemAdded

but it's not firing when I'm creating a new document or uploading one to the library.

The code

        public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
        {
            SPRemoteEventResult _result = new SPRemoteEventResult();

            try 
            { 
                switch(properties.EventType)
                {
                    case SPRemoteEventType.ItemAdded:
                        HandleAutoTaggingItemAdded(properties);
                        break;
                    case SPRemoteEventType.ItemAdding:
                        HandleAutoTaggingItemAdding(properties, _result);
                        break;
                }
                _result.Status = SPRemoteEventServiceStatus.Continue;
            }
            catch(Exception)
            {
                //You should log here.               
            }
            return _result;
        }

Isn't being hit. I haven't changed any code from the example so I'm not sure what I could be missing? The code example is three years old so could how to do things have been updated since then?

Thanks in advance.

2 Answers 2

1

Hard to say if this is all you need but ItemAdded events use the ProcessOneWayEvent method and not ProcessEvent. Notice how ProcessEvent returns a value; that's for async receivers like ItemAdding. That code will never get hit on ItemAdded.

https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/create-a-remote-event-receiver-in-sharepoint-add-ins

Also your web server's HTTP logs should be able to tell conclusively if requests have been made to it.

1

If you are using the modern library UI, I noticed events are not being triggered at all.

Try it on classic UI, if it works- you know this is the cause.

I have no solution currently for modern library UI supporting events, modern UI seems to broke event receivers.

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.