I have a sandbox solution. It has an event receiver. The event is triggered when a workflow is started.
It works in our dev environment. However, when the solution is deployed to Sharepoint Online, it doesn't work. It simply doesn't get triggered. Nothing happens. Even code for logging doesn't seem to be running. The code for the receiver goes like this:
public override void WorkflowStarted(SPWorkflowEventProperties properties)
{
base.WorkflowStarted(properties);
using (SPSite site = new SPSite(properties.WebUrl))
{
try
{
// Lots of stuff
}
catch (Exception ex)
{
using (SPWeb web = site.OpenWeb())
{
SPWorkflow.CreateHistoryEvent(web, properties.InstanceId,
10, // Workflow Error
web.CurrentUser,
new TimeSpan(0, 0, 0),
"some text",
"some more text: " + ex.Message,
"");
}
}
}
}
Also the xml:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Receivers ListUrl="Lists/myListNameHere">
<Receiver>
<Name>snip</Name>
<Type>WorkflowStarted</Type>
<Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
<Class>Foo.Bar</Class>
<SequenceNumber>10000</SequenceNumber>
<Synchronization>Synchronous</Synchronization>
</Receiver>
</Receivers>
</Elements>
So in the dev environment, when an exception is thrown, it's written to the workflow's history (double-checked and working). In Sharepoint online, I don't see any exceptions on the list's history. The only thing that's in the history of the workflow is an entry saying it's completed successfully. Add the fact that in the Sharepoint Online environment, you can't:
- Use Powershell (and Sharepoint Online Management Shell is not supported either, since we're not beta users) to see if the receiver is attached to the list;
- Debug, for obvious reasons;
- Get the logs on the hive directory;
We're pretty lost.
I have already checked that my user has full control on the site. I have already checked this question and yes, I have activated the solution and the feature. I have actually checked all the questions that Stack Exchange suggested as I type this. And still I'm coming up with nothing.
What might I be doing wrong? How can I find out more about what's happening?
Edit: Some event receivers are working. I have found out that only workflow event receivers don't work. So I changed the code in a working item added
receiver to fetch information about the offending receivers and store it in a list item.
Looking at this information, I've found out that all the receivers are attached correctly to their respective lists. However, even the simplest code like changing the value of a field of an item doesn't work inside workflow event receivers (workflow starting, workflow started and workflow completed).