1

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).

1 Answer 1

2

What you can try is to attach your event receiver on feature activation. you would just need to have a feature receiver within your event receiver. In that you can just attach the event receiver you created or in the feature receiver you can also check if there are attached receivers in your SPList.

SPList.EventReceivers

Edit: With regards with the debugging can you just deploy your sandbox solution directly from Visual Studio and then Attach to process with process named as SPUCWorkerProcess?

9
  • I can debug it on the dev environment and it works fine. I can't debug it when it's running in Sharepoint Online. I will try using feature receivers to force the event to be attached, though, so thanks for the suggestion :) I'll be back to mark this as the answer if it works.
    – Geeky Guy
    May 31, 2013 at 12:22
  • So I just checked it out. The event is attached alright. Still doesn't work.
    – Geeky Guy
    May 31, 2013 at 14:50
  • can you try to do the logging first before any other process just for us to check if the event really is firing May 31, 2013 at 15:44
  • Did that. The event doesn't log anything in Sharepoint Online.
    – Geeky Guy
    May 31, 2013 at 16:57
  • Not sure if this would help but can you try if the tool for SharePoint Online 2013 would work on SharePoint Online? here's the link Jun 2, 2013 at 7:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.