Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a SP 2010 site workflow with an InfoPath initialization form. After the user fills in the data in the init form he submits the form and the workflow starts with the WorkflowActivated event.

If WorkflowActivated throws an exception, how do I notify the user of the error? The form is closed and worked well but everything failed after control reached the Workflow.

Is there a way to somehow notify the user that the workflow failed to start?

share|improve this question
add comment

1 Answer 1

Why not use the SPUtility.SendEmail() method in your catch block?

try
{
  // Do stuff
}
catch (Exception ex)
{
  // Handle error

  string strUserEmailAddress = "Set the email address here";
  string strSubject = "Workflow Failed to Start";
  string strHTMLBody = "<body><div>Format some message here</div></body>";

  using (SPSite site = new SPSite("siteurl"))
  {
    using (SPWeb web = site.RootWeb)
    {
      SPUtility.SendEmail(web, true, false, 
                          strUserEmailAddress, strSubject, strHTMLBody);
    }
  }
}

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.sendemail.aspx

share|improve this answer
    
Unfortunately that won't work. The application already sends mails, the user can go to multiple pages and see if all was OK (workflow creates visible items in the site) etc. But user won't do that. He enters the data, then it's "fire and forget". I need an immediate feedback! –  JohnDoDo Jul 20 '12 at 7:12
    
The workflow code is running outside of the context of the browser, so how else would you inform the user? You could write some kind of custom ticker control and throw it in the master page and have it read data from a list. Then instead of email you could just write an item to the list. But that is way more complicated, and you have to set up filtering based on the user who is logged in. Sending an email to let them know they need to resubmit that form is the simplest and quickest way to ensure this information reaches your user. –  RJ Cuthbertson Jul 20 '12 at 16:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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