2

I want to develop my first sharepoint add-in for implementing a remote event receiver. so i did these steps, without any success in forcing the RER to fire:-

  1. I have office 365 + Visual Studio 2015 professional.
  2. I open VS 2015 -> create a new project of type SharePoint Add-in:- enter image description here
  3. then i enter the following:-
    • Team site collection url
    • add-in type as SharePoint-hosted

enter image description here 4. after that i mention that the type is for office 365:- enter image description here 5. i right click on the project>> new item >> RER + to fire on custom lists when items are being added: enter image description here enter image description here 6. then i added this test code inside the remote event receiver, to update a custom list items' title to be "updated title":-

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

            using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
            {
                if (clientContext != null)
                {
                    if (properties.EventType == SPRemoteEventType.ItemAdding)
                    {
                        result.ChangedItemProperties.Add("Title", "updated title");

                    }
                  //  clientContext.Load(clientContext.Web);
                  //  clientContext.ExecuteQuery();
                }
            }

            return result;
        }

7. then i try running the project but i got this error:-

Error occurred in deployment step 'Install SharePoint Add-in': Sideloading of apps is not enabled on this site.

so i realize that i can not directly add my add-in to a team site. 8. so i changed the add-in url to use the developer site url. 9. then i run the add-in, and i got this page, which seems inside my dev site collection:- enter image description here

  1. so i trusted the app, then i add a new custom list, but when i add a new item inside the new custom list, title did not get modified, so seems the RER did not get fired.

so are my above steps valid? or there is something missing?

Thanks

2

RERs can only be Provider Hosted. You've set up your Addin as SharePoint Hosted.

Use remote event receivers in SharePoint

SharePoint-hosted add-ins do not support remote event receivers. To use remote event receivers, you need to use a provider-hosted add-in. You should not use remote event receivers for synchronization scenarios, or for long running processes. For more information, see How to: Create an add-in event receiver.

  • but all over the web and YouTube you can find RER being added at first as sharepoint-hosted add-in , then when you add a RER item inside the sharepoint hosted add-in a new web project of type provider-hosted will be created.. and almost every tutorial i viewed ,start by creating sharepoint-hosted app and not provider-hosted... – john Gu Jan 9 '18 at 16:38
  • I'd suggest you read the documentation, it's clear that RERs are only supported in Provider Hosted addins. Yes, there is a SharePoint component ("addin"), but that's just for authorization/trust purposes. – Trevor Seward Jan 9 '18 at 16:39
  • @Trvor ok now i created a new provider hosted app, then i added a new RER, after that i run the application which get hosted inside this url https://localhost:44313/Pages/Default.aspx?SPHostUrl=https://a*****.sharepoint.com/sites/dev&SPLanguage=en-US&SPClientTag=0&SPProductNumber=16.0.7213.1208&SPAppWebUrl=https://*****SP-2c49524ea3c40a.sharepoint.com/sites/dev/SharePointAddIn19 but when i added a new item inside my custom list its title did not change... so seems the RER is not working – john Gu Jan 9 '18 at 16:48

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.