0
votes

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.

Thanks.

1
can't send email through code? why? some moral restriction?Gusman
I have no morals when it comes to coding ;) But really - it's just an example. I wish to take advantage of the workflow designer where possible. No point reinventing the wheel. So coming out of the custom code into the designer workflow will be advantageous.plusheen
Then nothing blocks you to send emails through code, look at the SmtpClient classGusman
That's true, I can send the e-mail using the SmptClient or even the Mail messages CRM has - but again it was just an example. My question is less about solving the immediate issue, but the capabilities CRM workflows have, and if its possible to intertwine the two, jumping in and out of custom code depending on statuses.plusheen
What's the product version/SKU you are using? 2013/2015/2016, OnPremise/Online?Henk van Boeijen

1 Answers

2
votes

Plusheen,

You can set an output parameter in your custom code based on your requirement and access that in your next step in out of the box workflow designer. Use a condition expression in the designer to check the output and do what you want to do based on the result from the Custom code.

Hope this is something what you were looking for. Let me know if you need any more information.