I have created this Sandboxed Event Receiver on ItemAdding on a custom list.
It works on my on-premise server, but it does not work on Sharepoint Online aka. O365.
Anybody know how to create an Event Receiver in Sharepoint Online, I will be really thankful!
----- EDIT ----
using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;
namespace Change_Title_Event.Change_Title
{
/// <summary>
/// List Item Events
/// </summary>
public class Change_Title : SPItemEventReceiver
{
/// <summary>
/// An item is being added.
/// </summary>
public override void ItemAdding(SPItemEventProperties properties)
{
properties.AfterProperties["Title"] = "Kevin: Changed by event receiver at" + DateTime.Now.TimeOfDay.ToString();
base.ItemAdding(properties);
}
}
}
Elements.xml
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Receivers ListTemplateId="100">
<Receiver>
<Name>Change_TitleItemAdding</Name>
<Type>ItemAdding</Type>
<Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
<Class>Change_Title_Event.Change_Title.Change_Title</Class>
<SequenceNumber>10000</SequenceNumber>
</Receiver>
</Receivers>
</Elements>
Scope is Web and the Item is in the Feature.
-------- EDIT 2 ----------
using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;
namespace Change_Title_Event.Change_Title
{
/// <summary>
/// List Item Events
/// </summary>
public class Change_Title : SPItemEventReceiver
{
/// <summary>
/// An item was added
/// </summary>
public override void ItemAdded(SPItemEventProperties properties)
{
base.ItemAdded(properties);
properties.ListItem["Title"] = "Kevin: Changed by event receiver at" + DateTime.Now.TimeOfDay.ToString();
properties.ListItem.Update();
}
}
}
This code works on on-premise, but do not work on Sharepoint Online.
Does somebody has a working solution (.wsp), that works on Sharepoint Online?