0

I have create a Remote Event Receiver, the code is working when it is deployed to a custom list but when I try to deploy it to a Document Library, ItemAdded is not firing

code snippets:

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

            // On Item Added event, the list item creation executes
            if (properties.EventType == SPRemoteEventType.ItemAdding)
            {
                using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
                {
                    if (clientContext != null)
                    {
                        try
                        {

                            string title = properties.ItemEventProperties.AfterProperties["Title"].ToString();
                            Guid guid = Guid.NewGuid();
                            string str = guid.ToString();

                            List lstDemoeventReceiver = clientContext.Web.Lists.GetByTitle(properties.ItemEventProperties.ListTitle);
                            ListItem itemDemoventReceiver = lstDemoeventReceiver.GetItemById(properties.ItemEventProperties.ListItemId);

                            itemDemoventReceiver["TestId"] = str;
                            itemDemoventReceiver.Update();
                            clientContext.ExecuteQuery();
                        }
                        catch (Exception ex) { }
                    }
                }


            }
            return result;
        }
0

Did you upload the same file existed to the library ? If then ItemAdding event won't trigger as SharePoint will regard it as a Update event, only a new file upload will be regarded as ItemAdding, so if there is already document existed, please Write logic in ItemUpdated Event:

Office 365 document library remote event receiver issue

0

ItemAdding event is not working on modern library UI.

Try it on classic UI, it should work if you did everything else correctly.

Seems like modern library UI broke the event receivers API.

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.