Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save lesagesander/a385ac012f3f7db0b98e to your computer and use it in GitHub Desktop.
//do not forget to reference officeams.core ( dll to call extension methods.
//create settingslist
hostWebClientContext.Web.AddList(100, new Guid("00bfea71-de22-43b2-a848-c05709900100"), "Settings", false);
//get settings list
var settingsList = hostWebClientContext.Web.GetListByTitle("Settings");
//prepare eventreceiver binding
var eventReceivers = settingsList.EventReceivers;
//since this code example is running in a web service class during AppInstalled event,
//we can get the remoteweb url from the WebOperationContext
//remoteWebUrl will result in: ""
var remoteWebUrl = string.Empty;
if(null != WebOperationContext.Current)
remoteWebUrl = WebOperationContext.Current.IncomingRequest.Headers["Host"];
//little trick to be able to debug our event receiver
remoteWebUrl = String.Format("https://{0}/3458491647/3050950848/obj/f44563bb-02a0-4a5b-b2da-737023b5a03e", remoteWebUrl);
var settingsRerAdded = new EventReceiverDefinitionCreationInformation
ReceiverUrl = String.Format("{0}{1}", remoteWebUrl, "SettingsEvents.svc"),
ReceiverName = "SettingsEventReceiverAdded",
Synchronization = EventReceiverSynchronization.Synchronous,
SequenceNumber = 10000,
EventType = EventReceiverType.ItemAdded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment