views:

1452

answers:

5

I have a custom action in a workflow and would like to report an error to the user when something goes wrong. What's the best way of doing that?

UPD: Ideally I would like to put the workflow in the error state and log a message to the workflow log. That doesn't seem possible. What's the closest I can get to it? I want to a reusable solution,something that's easy for users to set up when using my custom action in SharePoint Designer.

A: 

Add the error to a hidden list with that users name. Set the visibility on the list (for users) to only read/write their own values. Then use a custom web part or FlexListViewer to view the contents of that list and display it to the user. Once they acknowledge that error, remove it from the list.

If necessary, you can add a different workflow action on that message list, that says pause for 2 days and then email. Whatever, depending on your requirements.

Otherwise you can have a custom db table that you use for pretty much the same thing, this way sharepoint does most of the work for you.

Update This can be packaged up as a feature and deployed to each site as needed. The strengths of this approach (adding a list item to a list, querying, alerting a user, and emailing a user) are all built into the sharepoint itself. In this case you can focus on your custom logic only, while letting sharepoint focus on the implementation details.

AdamSane
A: 

Personally I would log it to either a log file or the event log depending on the issue. I think storing it using a users permissions would be a bad idea, what happens if that user does not have the correct rights? or worse still they get elevated permissions by browsing the list in explorer view?

The log file would be the best way, that way you rely only on the file system being available - you dont have to worry about trapping errors happening whilst connecting to the database etc.

Mauro

A: 

Added more details to the question.

@mauro that takes care of storing the error, but how do I display the error to the user in a way which makes sense?

@AdamSane That's seems like a rather fragile solution. It's not a matter of setting this up once on a single site. I need something others can add using SPD.

Eugene Katz
+1  A: 

when you throw the error your error handler can then email the user, or better if the list is massive, add the error state to the workflow item - i think this is default functionality though as the error would be mentioned there.

http://www.sharepointsecurity.com/blog/sharepoint/sharepoint-2007-development/fault-handling-in-sharepoint-workflows/

A: 

If you need the user to take some action as a result of the error (e.g. retrying the workflow) is it possible to create a task for that user with information on the error and the location of the workflow?

Nat
that's what I'm trying to do, but having problems actually getting the error:http://stackoverflow.com/questions/15053/how-to-get-out-parameters-working-in-sharepoint-workflowsand http://stackoverflow.com/questions/33349/looking-up-document-library-items-in-a-sharepoint-workflow
Eugene Katz