0

I want to attach Item Added remote event receiver to every new list created by user so I want to create remote event receiver for List Added event. Please help.

0

This is what I was looking for:

`private void AppInstalledMethod(SPRemoteEventProperties _properties)
    {
        using (ClientContext clientContext = TokenHelper.CreateAppEventClientContext(_properties, false))
        {
            if (clientContext != null)
            {
                Web web = clientContext.Web;
                clientContext.Load(web);
                clientContext.Load(clientContext.Site);
                clientContext.Load(clientContext.Site.EventReceivers);
                clientContext.ExecuteQuery();
                EventReceiverDefinitionCreationInformation receiver = new EventReceiverDefinitionCreationInformation();
                receiver.EventType = EventReceiverType.ListAdded;
                OperationContext op = OperationContext.Current;
                Message msg = op.RequestContext.RequestMessage;
                receiver.ReceiverUrl = msg.Headers.To.ToString();
                receiver.ReceiverName = "EventForNewLibrary";
                receiver.Synchronization = EventReceiverSynchronization.Synchronous;
                receiver.SequenceNumber = 5000;
                clientContext.Site.EventReceivers.Add(receiver);
                clientContext.ExecuteQuery();
            }
        }
    }`

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.