I'm developing a few custom CRM workflows, and some of them require e-mails to be sent. As far as i'm aware, this can't be done through code. What I would like to achieve is - to run some custom code, and depending on what happens during that code, i.e. a timeout exception to a web service throws an exception or a validation error occurs for said web service, the workflow will either retry or send an email out.
So, using above example, the custom workflow is run when a CRM field changes. The workflow calls a web service, which times out. The workflow then picks up that it was a
TimeoutException, and adds a step to retry the workflow. The workflow restarts, and throws an
ArgumentException. The workflow picks up this exception, and sets a field in the form. (I understand this can be done in the code, it is just an example, as I wish to use this functionality for many areas in many workflows!)
The only way I thought of was to have a new field on the form called Workflow Action, have the workflow detect changes, and the custom code changes this field. The workflow knows what status it has changed to and behaves accordingly.