{"id":1326,"date":"2018-09-07T12:42:28","date_gmt":"2018-09-07T12:42:28","guid":{"rendered":"https:\/\/www.tatvasoft.com.au\/blog\/?p=1326"},"modified":"2022-03-17T07:41:38","modified_gmt":"2022-03-17T07:41:38","slug":"how-to-implement-remote-event-receiver-in-sharepoint-online","status":"publish","type":"post","link":"https:\/\/www.tatvasoft.com.au\/blog\/how-to-implement-remote-event-receiver-in-sharepoint-online\/","title":{"rendered":"How to Implement Remote Event Receiver in SharePoint Online"},"content":{"rendered":"<p>The scenario to deal with creating files in document libraries, adding\/updating\/deleting items in the SharePoint list, at times requirement emerges to perform some action on such events like sending notification, data manipulation on SharePoint lists or libraries, etc.<\/p>\n<p><span id=\"more-911\"><\/span> In <a href=\"https:\/\/www.tatvasoft.com.au\/technologies\/sharepoint-development\/\">SharePoint Development<\/a>, there are two manners to achieve this \u2013 SharePoint Designer Workflow and Event Receivers. Of course we can use these techniques to achieve such requirement, but it runs on SharePoint server, i.e. business logic runs on the same server where SharePoint is installed, and event receivers do not support while working with <a href=\"https:\/\/www.tatvasoft.com.au\/blog\/office-365-is-emerging-rapidly-in-enterprises\/\">Office 365 \u2013 SharePoint online<\/a>. Few SharePoint programmers while consulting process may pitch to use different approaches like provider hosted-apps.<\/p>\n<p>Cases where the business requirements are to keep business logic and SharePoint server segregated. Fortunately to deal with document libraries\/lists on a host web (on which site we install application), it provides concept called Remote Event Receiver.If any list item is added\/edited\/deleted, and we want to perform any action like sending notification, we can use a remote event receiver.<\/p>\n<p>So, let\u2019s learn how to prepare provider hosted app and remote event receiver. We will host Provider Hosted application in Azure. Below are mentioned the steps to create remote event receiver.<\/p>\n<p>Following are the tools to create remote Event Receiver:<\/p>\n<ol class=\"sharepoint-order-list\">\n<li>Visual Studio 2015<\/li>\n<li>SharePoint Online (Office 365)<\/li>\n<li>Azure Portal (For Deployment)<\/li>\n<\/ol>\n<h2>Step 1 \u2013 To Create Provider Hosted Application<\/h2>\n<ol class=\"sharepoint-order-list\">\n<li>Open Visual studio<\/li>\n<li>Click on File\u00a0 New Project.<\/li>\n<li>Dialog box will appear. Select Templates then Visual C# then Office\/SharePoint.<\/li>\n<li>Select \u201cApp for SharePoint\u201d, make sure .Net framework 4.5 is selected, for more information review below screen shot and give application \u201cHelloWorldProvider\u201d name.<img loading=\"lazy\" class=\"wp-image-913 alignnone\" title=\"Open New project\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Open-New-project.png\" sizes=\"(max-width: 508px) 100vw, 508px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Open-New-project.png 957w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Open-New-project-300x208.png 300w\" alt=\"Open New project\" width=\"508\" height=\"352\" \/><\/li>\n<li>Then choose a SharePoint developer site and then choose Provider-hosted like below. You can see below article to know how we can create a developer site in SharePoint, for more information review below screen shot, for security reasons we<br \/>\nhave erased URL.<img loading=\"lazy\" class=\"wp-image-928 size-full alignnone\" title=\"New App for Sharepoint\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/New-App-for-Sharepoint.png\" sizes=\"(max-width: 388px) 100vw, 388px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/New-App-for-Sharepoint.png 388w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/New-App-for-Sharepoint-300x214.png 300w\" alt=\"New App for Sharepoint\" width=\"388\" height=\"277\" \/><\/li>\n<li>Then it will ask to give credentials for the developer site and then select SharePoint Online Version.<\/li>\n<li>Then wizard will ask which type of provider application, we want to create either Asp.Net web forms or ASP.Net MVC application. Currently, we will select ASP.Net web forms.<\/li>\n<li>On the next screen selection option \u201cUse Windows Azure Access Control Service (for SharePoint cloud apps)\u201d.<\/li>\n<li>It will take some time and it will create two projects in one solution, one is for the SharePoint add-in and the other will be ASP.NET web forms project, review below image for more information:<img loading=\"lazy\" class=\"wp-image-929 alignnone\" title=\"Solution Explorer\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Solution-Provider.png\" sizes=\"(max-width: 357px) 100vw, 357px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Solution-Provider.png 377w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Solution-Provider-210x300.png 210w\" alt=\"Solution Explorer\" width=\"357\" height=\"510\" \/><\/li>\n<li>We need to attach event receiver to the list of host web (where we install add-in), so to achieve this, select add-in project from the solution and from the properties of the project set \u201cHandle App Installed\u201d to \u2018true\u2019:<img loading=\"lazy\" class=\"wp-image-930 size-full alignnone\" title=\"Set Solution Explorer\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Solution-Explorer.png\" sizes=\"(max-width: 463px) 100vw, 463px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Solution-Explorer.png 463w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Solution-Explorer-161x300.png 161w\" alt=\"Set Solution Explorer\" width=\"463\" height=\"865\" \/><\/li>\n<li>After setting \u201cHandle App Installed\u201d property to true, AppEventReceiver.svc will be added inside the Services folder like below: We are going to write code to attach remote event receiver to host web\u2019s list.<img loading=\"lazy\" class=\"wp-image-931 alignnone\" title=\"App Event Receiver\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/App-Event-Receiver.png\" sizes=\"(max-width: 411px) 100vw, 411px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/App-Event-Receiver.png 464w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/App-Event-Receiver-243x300.png 243w\" alt=\"App Event Receiver\" width=\"411\" height=\"507\" \/><\/li>\n<\/ol>\n<h2>Step 2 \u2013 To Add Remote Event Receiver to project<\/h2>\n<ol class=\"sharepoint-order-list\">\n<li>Add Remote Event Receiver. Right click on the Add-in project then Add then New Item.<img loading=\"lazy\" class=\"wp-image-933 alignnone\" title=\"Add Remote Event Receiver\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Add-Remote-Event-Receiver.png\" sizes=\"(max-width: 452px) 100vw, 452px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Add-Remote-Event-Receiver.png 819w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Add-Remote-Event-Receiver-300x268.png 300w\" alt=\"Add Remote Event Receiver\" width=\"452\" height=\"405\" \/><\/li>\n<li>Give it name \u201cValidation\u201d.<img loading=\"lazy\" class=\"wp-image-934 alignnone\" title=\"Saved as Validation\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Save-as-Validation.png\" sizes=\"(max-width: 564px) 100vw, 564px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Save-as-Validation.png 952w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Save-as-Validation-300x209.png 300w\" alt=\"Saved as Validation\" width=\"564\" height=\"392\" \/><\/li>\n<li>Select List Item Events, event source as Custom List and then event as \u201cAn Item was added\u201d, which means some action on the host web\u2019s list will be performed when an item is added in that list.<img loading=\"lazy\" class=\"wp-image-935 alignnone\" title=\"Choose Event receiver settings\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Choose-Event-receiver-settings.png\" sizes=\"(max-width: 567px) 100vw, 567px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Choose-Event-receiver-settings.png 685w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Choose-Event-receiver-settings-300x219.png 300w\" alt=\"Choose Event receiver settings\" width=\"567\" height=\"415\" \/><\/li>\n<li>Validation.svc file will be added to add-in project as well as inside the service folder of the asp.net web forms project. Review below image:<img loading=\"lazy\" class=\"wp-image-936 alignnone\" title=\"Validation.svc file\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Validation.svc-file.png\" sizes=\"(max-width: 430px) 100vw, 430px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Validation.svc-file.png 443w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Validation.svc-file-234x300.png 234w\" alt=\"Validation.svc file\" width=\"430\" height=\"550\" \/><\/li>\n<\/ol>\n<h2>Step 3 \u2013 To Generate Client ID &amp; Client Secret<\/h2>\n<ol class=\"sharepoint-order-list\">\n<li>To establish trust with the provider hosted web, we need to generate the Client ID and Client Secret. So navigate to the _layouts\/15\/appregnew.aspx pageExample: https:\/\/test.sharepoint.com\/sites\/devsite\/_layouts\/15\/appregnew.aspx<\/li>\n<li>Click on the Generate button for the Client Id and Client Secret fields to generate them respectively. Enter a title and in App Domain put the website that is created in azure (without https). Lastly, enter the Redirect URI which is the website<br \/>\nURL, make sure to give in https.<img loading=\"lazy\" class=\"wp-image-937 alignnone\" title=\"App Information\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/App-Information.png\" sizes=\"(max-width: 678px) 100vw, 678px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/App-Information.png 916w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/App-Information-300x116.png 300w\" alt=\"App Information\" width=\"678\" height=\"262\" \/><\/li>\n<li>\u00a0Open the web.config file and replace the Client Id and Client Secret which we have generated in the above page. Note: Before modifying the web.config file, take its backup.<\/li>\n<li>On AppManifest.xml, Right Click then View Code and add following code:\n<div class=\"wp_syntax\" style=\"position: relative;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"javascript\" style=\"font-family: monospace;\">&lt;AppPermissionRequests AllowAppOnlyPolicy=\"false\"&gt;\r\n    &lt;AppPermissionRequest Scope=\"http:\/\/sharepoint\/content\/sitecollection\/web\" Right=\"FullControl\" \/&gt;\r\n&lt;\/AppPermissionRequests&gt;<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"theCode\" style=\"display: none;\">&lt;AppPermissionRequests AllowAppOnlyPolicy=&#8221;false&#8221;&gt; &lt;AppPermissionRequest Scope=&#8221;http:\/\/sharepoint\/content\/sitecollection\/web&#8221; Right=&#8221;FullControl&#8221; \/&gt; &lt;\/AppPermissionRequests&gt;<\/p>\n<\/div>\n<p>Also add client ID same as above<\/li>\n<\/ol>\n<h2>Step 4 \u2013 To Add Code to AppEventReceiver<\/h2>\n<p>In <strong>ASP.Net Web forms project<\/strong> inside the service folder\u2019s <strong>AppEventReceiver.svc.cs<\/strong> file, we will add the code to attach the event receiver to the host list. The code will be added in the <strong>ProcessEvent<\/strong> event for the <strong>AppInstalled<\/strong> event.<\/p>\n<div class=\"wp_syntax\" style=\"position: relative;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"javascript\" style=\"font-family: monospace;\">public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)\r\n\u00a0\r\n{\r\n\u00a0\r\ntry\r\n\u00a0\r\n{\r\n\u00a0\r\nSPRemoteEventResult result = new SPRemoteEventResult();\r\n\u00a0\r\n\u00a0\r\nusing (ClientContext clientContext = TokenHelper.CreateAppEventClientContext(properties, useAppWeb: false))\r\n\u00a0\r\n{\r\n\u00a0\r\nif (clientContext != null)\r\n\u00a0\r\n{\r\n\u00a0\r\nclientContext.Load(clientContext.Web);\r\n\u00a0\r\nclientContext.ExecuteQuery();\r\n\u00a0\r\n\u00a0\r\nif (properties.EventType == SPRemoteEventType.AppInstalled)\r\n\u00a0\r\n{\r\n\u00a0\r\n\/\/Get reference to the host web list with name Feedback\r\n\u00a0\r\nvar documentsList = clientContext.Web.Lists.GetByTitle(\"MDLIB\");\r\n\u00a0\r\nclientContext.Load(documentsList);\r\n\u00a0\r\nclientContext.ExecuteQuery();\r\n\u00a0\r\nstring remoteUrl = \"https:\/\/customproviderhosted.azurewebsites.net\/Services\/Validation.svc\";\r\n\u00a0\r\n\/\/Create the remote event receiver definition\r\n\u00a0\r\nEventReceiverDefinitionCreationInformation remoteEventReceiver1ItemAdded = new EventReceiverDefinitionCreationInformation()\r\n\u00a0\r\n{\r\n\u00a0\r\nEventType = EventReceiverType.ItemUpdated,\r\n\u00a0\r\nReceiverAssembly = Assembly.GetExecutingAssembly().FullName,\r\n\u00a0\r\nReceiverName = \"ValidationItemAdded\",\r\n\u00a0\r\nReceiverClass = \"Validation\",\r\n\u00a0\r\nReceiverUrl = remoteUrl,\r\n\u00a0\r\nSequenceNumber = 10000,\r\n\u00a0\r\n};\r\n\u00a0\r\n\u00a0\r\n\/\/Add the remote event receiver to the host web list\r\n\u00a0\r\ndocumentsList.EventReceivers.Add(remoteEventReceiver1ItemAdded);\r\n\u00a0\r\nclientContext.ExecuteQuery();\r\n\u00a0\r\n}\r\n\u00a0\r\n}\r\n\u00a0\r\n}\r\n\u00a0\r\n}\r\n\u00a0\r\ncatch (Exception ex) {\r\n\u00a0\r\nSPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(\"Remote Event Receiver - Error Report\", TraceSeverity.High, EventSeverity.ErrorCritical), TraceSeverity.High, ex.Message, string.Empty);\r\n\u00a0\r\n}\r\n\u00a0\r\nreturn result;\r\n\u00a0\r\n}<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"theCode\" style=\"display: none;\">public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties) { try { SPRemoteEventResult result = new SPRemoteEventResult(); using (ClientContext clientContext = TokenHelper.CreateAppEventClientContext(properties, useAppWeb: false))<br \/>\n{ if (clientContext != null) { clientContext.Load(clientContext.Web); clientContext.ExecuteQuery(); if (properties.EventType == SPRemoteEventType.AppInstalled) { \/\/Get reference to the host web list with name Feedback var documentsList = clientContext.Web.Lists.GetByTitle(&#8220;MDLIB&#8221;);<br \/>\nclientContext.Load(documentsList); clientContext.ExecuteQuery(); string remoteUrl = &#8220;https:\/\/customproviderhosted.azurewebsites.net\/Services\/Validation.svc&#8221;; \/\/Create the remote event receiver definition EventReceiverDefinitionCreationInformation<br \/>\nremoteEventReceiver1ItemAdded = new EventReceiverDefinitionCreationInformation() { EventType = EventReceiverType.ItemUpdated, ReceiverAssembly = Assembly.GetExecutingAssembly().FullName, ReceiverName = &#8220;ValidationItemAdded&#8221;, ReceiverClass = &#8220;Validation&#8221;,<br \/>\nReceiverUrl = remoteUrl, SequenceNumber = 10000, }; \/\/Add the remote event receiver to the host web list documentsList.EventReceivers.Add(remoteEventReceiver1ItemAdded); clientContext.ExecuteQuery(); } } } } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0,<br \/>\nnew SPDiagnosticsCategory(&#8220;Remote Event Receiver &#8211; Error Report&#8221;, TraceSeverity.High, EventSeverity.ErrorCritical), TraceSeverity.High, ex.Message, string.Empty); } return result; }<\/p>\n<\/div>\n<p>Above code will attach remote event receiver to the list named \u201cMDLIB\u201d which will be in host web (i.e. where provider hosted app is going to be installed).<\/p>\n<h2>Step 5 \u2013 To Add Code to Validation Remote Event Receiver<\/h2>\n<p>In <strong>ASP.Net web forms project<\/strong> inside the service folder\u2019s <strong>Validation.svc.cs<\/strong> file, we will add the code to instruct event receiver to updated description field of <strong><em>\u2018MDLIB\u2019<\/em><\/strong> list when item added.<br \/>\nThe code will be added in the <strong>ProcessOneWayEvent<\/strong> event.<\/p>\n<div class=\"wp_syntax\" style=\"position: relative;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"javascript\" style=\"font-family: monospace;\">public void ProcessOneWayEvent(SPRemoteEventProperties properties)\r\n\u00a0\r\n{\r\n\u00a0\r\nif (properties.EventType == SPRemoteEventType.ItemAdded)\r\n\u00a0\r\n{\r\n\u00a0\r\nusing (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))\r\n\u00a0\r\n{\r\n\u00a0\r\nif (clientContext != null)\r\n\u00a0\r\n{\r\n\u00a0\r\ntry\r\n\u00a0\r\n{\r\n\u00a0\r\n\u00a0\r\nList lstDemoeventReceiver = clientContext.Web.Lists.GetByTitle(properties.ItemEventProperties.ListTitle);\r\n\u00a0\r\nListItem itemDemoventReceiver = lstDemoeventReceiver.GetItemById(properties.ItemEventProperties.ListItemId);\r\n\u00a0\r\n\u00a0\r\nitemDemoventReceiver[\"Description\"] = \" updated by remote event reciever =&gt;; \" + DateTime.Now.ToString();\r\n\u00a0\r\nitemDemoventReceiver.Update();\r\n\u00a0\r\nclientContext.ExecuteQuery();\r\n\u00a0\r\n}\r\n\u00a0\r\ncatch (Exception ex) {\r\n\u00a0\r\nSPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(\"Remote Event Receiver - Error Report\", TraceSeverity.High, EventSeverity.ErrorCritical), TraceSeverity.High, ex.Message, string.Empty);\r\n\u00a0\r\n}\r\n\u00a0\r\n}\r\n\u00a0\r\n}\r\n\u00a0\r\n}\r\n\u00a0\r\n}<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"theCode\" style=\"display: none;\">public void ProcessOneWayEvent(SPRemoteEventProperties properties) { if (properties.EventType == SPRemoteEventType.ItemAdded) { using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties)) { if (clientContext<br \/>\n!= null) { try { List lstDemoeventReceiver = clientContext.Web.Lists.GetByTitle(properties.ItemEventProperties.ListTitle); ListItem itemDemoventReceiver = lstDemoeventReceiver.GetItemById(properties.ItemEventProperties.ListItemId); itemDemoventReceiver[&#8220;Description&#8221;]<br \/>\n= &#8221; updated by remote event reciever =&gt;; &#8221; + DateTime.Now.ToString(); itemDemoventReceiver.Update(); clientContext.ExecuteQuery(); } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(&#8220;Remote Event Receiver<br \/>\n&#8211; Error Report&#8221;, TraceSeverity.High, EventSeverity.ErrorCritical), TraceSeverity.High, ex.Message, string.Empty); } } } } }<\/p>\n<\/div>\n<h2>Step 6 \u2013 To Deploy Provider Hosted App to Azure<\/h2>\n<ol class=\"sharepoint-order-list\">\n<li>Right click on the asp.net forms web project and then click on Publish.<img loading=\"lazy\" class=\"wp-image-939 alignnone\" title=\"Publish Web Project\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-Web-Project.png\" sizes=\"(max-width: 556px) 100vw, 556px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-Web-Project.png 575w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-Web-Project-300x140.png 300w\" alt=\"Publish Web Project\" width=\"556\" height=\"260\" \/><\/li>\n<li>Public web project dialog will appear, click on Microsoft Azure Web Apps.<img loading=\"lazy\" class=\"wp-image-940 alignnone\" title=\"Publish Microsoft Azure Web Apps\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-Microsoft-Azure-Web-Apps.png\" sizes=\"(max-width: 601px) 100vw, 601px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-Microsoft-Azure-Web-Apps.png 706w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-Microsoft-Azure-Web-Apps-300x237.png 300w\" alt=\"Publish Microsoft Azure Web Apps\" width=\"601\" height=\"475\" \/><\/li>\n<li>It will ask to login into azure account, it will display all the web apps. Choose the particular web apps like below:<img loading=\"lazy\" class=\"wp-image-941 alignnone\" title=\"login into azure account\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/login-into-azure-account.png\" sizes=\"(max-width: 617px) 100vw, 617px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/login-into-azure-account.png 724w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/login-into-azure-account-300x225.png 300w\" alt=\"login into azure account\" width=\"617\" height=\"464\" \/><\/li>\n<li>Publish method, Server, Site name, User name, Password and Destination URL will be appeared in next screen. Validate the connection and once it is successful.<img loading=\"lazy\" class=\"wp-image-942 alignnone\" title=\"Publish method\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-method.png\" sizes=\"(max-width: 571px) 100vw, 571px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-method.png 723w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-method-300x235.png 300w\" alt=\"Publish method\" width=\"571\" height=\"448\" \/><\/li>\n<li>Click on the Next.<img loading=\"lazy\" class=\"wp-image-943 alignnone\" title=\"Publish method Settings\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-method-Settings.png\" sizes=\"(max-width: 639px) 100vw, 639px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-method-Settings.png 719w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-method-Settings-300x237.png 300w\" alt=\"Publish method Settings\" width=\"639\" height=\"504\" \/><\/li>\n<li>To verify all the files, you can also click on the Start Preview button to see the preview.<img loading=\"lazy\" class=\"wp-image-944 alignnone\" title=\"Publish method Preview\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-method-Preview.png\" sizes=\"(max-width: 667px) 100vw, 667px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-method-Preview.png 717w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-method-Preview-300x236.png 300w\" alt=\"Publish method Preview\" width=\"667\" height=\"525\" \/><\/li>\n<\/ol>\n<h2>Step 7 \u2013 To Publish App Package<\/h2>\n<p>Now asp.net web project is published to azure web portal, now it\u2019s time to prepare package for the SharePoint add-in.<\/p>\n<ol class=\"sharepoint-order-list\">\n<li>Right-click on the Add-in Project and click on Publish.<img loading=\"lazy\" class=\"wp-image-946 size-full alignnone\" title=\"Publish Add in Project\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-Add-in-Project.png\" sizes=\"(max-width: 465px) 100vw, 465px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-Add-in-Project.png 465w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-Add-in-Project-300x239.png 300w\" alt=\"Publish Add in Project\" width=\"465\" height=\"371\" \/><\/li>\n<li><strong>Publish your app<\/strong> page will appear, then click on the Edit button like below:<img loading=\"lazy\" class=\"wp-image-947 alignnone\" title=\"Edit Publish app\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-your-app.png\" sizes=\"(max-width: 629px) 100vw, 629px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-your-app.png 779w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Publish-your-app-300x267.png 300w\" alt=\"Publish your app\" width=\"629\" height=\"560\" \/><\/li>\n<li>It will ask <strong>Client ID<\/strong> &amp; <strong>Client Secret<\/strong>, write down both the same as we replaced into the web.config file.<img loading=\"lazy\" class=\"wp-image-948 alignnone\" title=\"Set app identity\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Set-Up-identity.png\" sizes=\"(max-width: 545px) 100vw, 545px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Set-Up-identity.png 603w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Set-Up-identity-300x252.png 300w\" alt=\"Set app identity\" width=\"545\" height=\"457\" \/><\/li>\n<li>Click on Package App, make sure that it is in release mode.<img loading=\"lazy\" class=\"wp-image-949 alignnone\" title=\"Package App\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Package-App.png\" sizes=\"(max-width: 512px) 100vw, 512px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Package-App.png 599w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Package-App-255x300.png 255w\" alt=\"Package App\" width=\"512\" height=\"603\" \/><\/li>\n<li>Here the website and Client Id will be populated by default. Click on Finish button which will generate the <strong>.app<\/strong><img loading=\"lazy\" class=\"wp-image-950 alignnone\" title=\"Finish Package the App\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Finish-Package-the-App.png\" sizes=\"(max-width: 534px) 100vw, 534px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Finish-Package-the-App.png 614w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/Finish-Package-the-App-300x268.png 300w\" alt=\"Finish Package the App\" width=\"534\" height=\"477\" \/><\/li>\n<li>It will open folder with package file (.app file).<\/li>\n<li>Open App Catalog site, go to Site Contents \u00e0 Apps for SharePoint \u00e0 Upload the <strong>.app<\/strong> file<\/li>\n<\/ol>\n<h4>Reference Sites:<\/h4>\n<ol class=\"sharepoint-order-list\">\n<li>App Catalog Site \u2013 https:\/\/docs.microsoft.com\/en-us\/sharepoint\/use-app-catalog<\/li>\n<li>Create developer site \u2013 https:\/\/docs.microsoft.com\/en-us\/sharepoint\/dev\/sp-add-ins\/create-a-developer-site-on-an-existing-office-365-subscription<\/li>\n<\/ol>\n<h2>Step 8 \u2013 To Test Remote Event Receiver<\/h2>\n<ol class=\"sharepoint-order-list\">\n<li>Go to site content of the developer site, and add an application.<\/li>\n<li>After the app is installed successfully, open the list and add an item to the list. Enter only <strong>Title<\/strong> and the <strong>Description<\/strong> will be added automatically by the remote event receiver like as shown below:<img loading=\"lazy\" class=\"wp-image-951 alignnone\" title=\"Add an item to the list\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/add-an-item-to-the-list.png\" sizes=\"(max-width: 579px) 100vw, 579px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/add-an-item-to-the-list.png 659w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/add-an-item-to-the-list-300x117.png 300w\" alt=\"add an item to the list\" width=\"579\" height=\"225\" \/><\/li>\n<\/ol>\n<h2>Conclusion<\/h2>\n<p>For the challenges part, there are few of them if the development is done using SharePoint Designer Workflow, but for Provider Hosted app it is way easier and safer as the business logic is not disclosed openly because it is hosted on separate individual server. Though details of each log can\u2019t be maintained on the server as it is an individual server, yet the process is more streamlined and robust.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The scenario to deal with creating files in document libraries, adding\/updating\/deleting items in the SharePoint list, at times requirement emerges&#8230;<\/p>\n","protected":false},"author":1,"featured_media":1377,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[29,32],"tags":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Learn how to Implement Remote Event Receiver in SharePoint Online<\/title>\n<meta name=\"description\" content=\"How to prepare provider hosted app and remote event receiver. We will host Provider Hosted application in Azure. Below are mentioned the steps to create.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.tatvasoft.com.au\/blog\/how-to-implement-remote-event-receiver-in-sharepoint-online\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Learn how to Implement Remote Event Receiver in SharePoint Online\" \/>\n<meta property=\"og:description\" content=\"How to prepare provider hosted app and remote event receiver. We will host Provider Hosted application in Azure. Below are mentioned the steps to create.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.tatvasoft.com.au\/blog\/how-to-implement-remote-event-receiver-in-sharepoint-online\/\" \/>\n<meta property=\"og:site_name\" content=\"TatvaSoft AU Blog\" \/>\n<meta property=\"article:published_time\" content=\"2018-09-07T12:42:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-03-17T07:41:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/remote-event-reciever-with-sharepoint-online.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"750\" \/>\n\t<meta property=\"og:image:height\" content=\"375\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"7 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.tatvasoft.com.au\/blog\/#website\",\"url\":\"https:\/\/www.tatvasoft.com.au\/blog\/\",\"name\":\"TatvaSoft AU Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.tatvasoft.com.au\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.tatvasoft.com.au\/blog\/how-to-implement-remote-event-receiver-in-sharepoint-online\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/09\/remote-event-reciever-with-sharepoint-online.jpg\",\"width\":750,\"height\":375,\"caption\":\"Remote Event Receiver in SharePoint Online\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tatvasoft.com.au\/blog\/how-to-implement-remote-event-receiver-in-sharepoint-online\/#webpage\",\"url\":\"https:\/\/www.tatvasoft.com.au\/blog\/how-to-implement-remote-event-receiver-in-sharepoint-online\/\",\"name\":\"Learn how to Implement Remote Event Receiver in SharePoint Online\",\"isPartOf\":{\"@id\":\"https:\/\/www.tatvasoft.com.au\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.tatvasoft.com.au\/blog\/how-to-implement-remote-event-receiver-in-sharepoint-online\/#primaryimage\"},\"datePublished\":\"2018-09-07T12:42:28+00:00\",\"dateModified\":\"2022-03-17T07:41:38+00:00\",\"author\":{\"@id\":\"https:\/\/www.tatvasoft.com.au\/blog\/#\/schema\/person\/99be98dec950f3b1cdc014df166dd95c\"},\"description\":\"How to prepare provider hosted app and remote event receiver. We will host Provider Hosted application in Azure. Below are mentioned the steps to create.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.tatvasoft.com.au\/blog\/how-to-implement-remote-event-receiver-in-sharepoint-online\/\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.tatvasoft.com.au\/blog\/#\/schema\/person\/99be98dec950f3b1cdc014df166dd95c\",\"name\":\"tatvasoftadmin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.tatvasoft.com.au\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1ef69a3ae4a620ca0f649d8228bece0b?s=96&d=mm&r=g\",\"caption\":\"tatvasoftadmin\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/posts\/1326"}],"collection":[{"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/comments?post=1326"}],"version-history":[{"count":35,"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/posts\/1326\/revisions"}],"predecessor-version":[{"id":1880,"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/posts\/1326\/revisions\/1880"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/media\/1377"}],"wp:attachment":[{"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/media?parent=1326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/categories?post=1326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/tags?post=1326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}