I have found the solution.
In the app installing event receiver AppEventReceiver.svc
you need to add the item events to your custom list List1
.
ProcessEvent
in AppEventReceiver.svc
is,
public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
{
SPRemoteEventResult result = new SPRemoteEventResult();
using (ClientContext clientContext = TokenHelper.CreateAppEventClientContext(properties, false))
{
if (clientContext != null)
{
var customList = clientContext.Web.Lists.GetByTitle("List1");
clientContext.Load(clientContext.Web);
clientContext.ExecuteQuery();
// debugging url
//string opContext = OperationContext.Current.Channel.LocalAddress.Uri.AbsoluteUri.Substring(
// 0, OperationContext.Current.Channel.LocalAddress.Uri.AbsoluteUri.LastIndexOf("/"));
//string remoteUrl = string.Format("{0}/RemoteEventReceiver1.svc", opContext);
// deployment
string remoteUrl = string.Format("https://{0}/RemoteEventReceiver1.svc",
OperationContext.Current.Channel.LocalAddress.Uri.DnsSafeHost + "/services");
EventReceiverDefinitionCreationInformation newEventReceiver = new EventReceiverDefinitionCreationInformation()
{
EventType = EventReceiverType.ItemAdding,
ReceiverName = "RemoteEventReceiver1",
ReceiverUrl = remoteUrl,
SequenceNumber = 1000
};
customList.EventReceivers.Add(newEventReceiver);
clientContext.ExecuteQuery();
}
}
return result;
}
Now, in RemoteEventReceiver1.svc
check the corresponding event type.
ProcessEvent
in RemoteEventReceiver1.svc
is,
public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
{
SPRemoteEventResult result = new SPRemoteEventResult();
if (properties.EventType == SPRemoteEventType.ItemAdding)
{
if (properties.ItemEventProperties.ListTitle == "List1")
{
var title = properties.ItemEventProperties.AfterProperties["Title"];
result.ChangedItemProperties.Add("Title", title + " title changed by RER");
result.Status = SPRemoteEventServiceStatus.Continue;
}
}
return result;
}
May be this will help someone.