Marek Grzenkowicz
Marek Grzenkowicz

Reputation: 17353

Is it possible to cancel a workflow activity in the MethodInvoking event handler?

I have a SharePoint workflow with a SendEmail activity. I use the MethodInvoking event handler to set the To property.

However, sometimes the workflow should not try to send an e-mail, because there is no e-mail address. I can detect such a condition in the MethodInvoking event handler. Is it possible to skip the SendEmail activity and proceed to the next one?

I know I can put IfElseActivity before SendEmail, but I am looking for a way to cancel activity execution.

Upvotes: 0

Views: 774

Answers (1)

Grace Note
Grace Note

Reputation: 3215

From looking at the SDK, all activities have a Cancelling event. However, what I find seems to suggest that an activity is only cancelled if the entire workflow hits an error or is cancelled. It does not appear that you can manually cancel a single activity (I'm not sure the workflow would know what to do next). So an IfElse branch, or a ConditionedActivityGroup, would probably be your best shot.

Upvotes: 1

Related Questions