currently I have project in SP Add-in model and I am using remote event receivers and have no problem with that.
Although now I am trying to migrate to HostWeb and I’m having some trouble setting up remote event receivers.
Through csom I add these events like this:
private static EventReceiverDefinitionCreationInformation CreateReceiverDefinition(string receiverUrl, string receiverName, EventReceiverType eventType, int sequenceNumber)
{
return new EventReceiverDefinitionCreationInformation
{
EventType = eventType,
ReceiverUrl = receiverUrl,
ReceiverName = receiverName,
SequenceNumber = sequenceNumber
};
}
private static void RegisterFormsListEvents(ClientContext context, string receiverUrl)
{
Logger.LogInfo("RegisterFormsListEventsHostWeb start");
if (context != null)
{
EventReceiverDefinitionCreationInformation itemDeleting = CreateReceiverDefinition(receiverUrl, "FormsListItemDeletingHostWeb", EventReceiverType.ItemDeleting, 10000);
var list = context.Web.Lists.GetByTitle(Core.Constants.ListTitles.FormsList);
list.EventReceivers.Add(itemDeleting);
context.ExecuteQueryAsync();
}
Logger.LogInfo("RegisterFormsListEventsHostWeb finish");
}
Receiver url goes to the same service i use for add in (which works), in the start of ProcessEvent() or ProcessOneWayEvent() I am loggging something like this:
public void ProcessOneWayEvent(SPRemoteEventProperties properties)
{
string listTitle = properties?.ItemEventProperties?.ListTitle;
Logger.LogInfo($"ProcessOneWayEvent start, listTitle:{listTitle}" + properties.EventType.ToString());
In the log file I am able to see if event was triggered.
So my event receivers gets added to both Addin and HostWeb and they are exactly the same of course except for id, but has same ReceiverUrl and etc, but none of events get caught from hostweb lists.
I’ve tried synchronous and asynchronous methods, various lists, I’ve compared hostweb with addin receivers (everything looks same) I’m not sure what else could be wrong.