Proper way to fail a custom workflow activity?
I am developing a custom workflow activity that does some looping to generate a unique account name. I want to put a sanity check in the code that aborts the loop after too many tries to find something unique. What is the proper way to abort a workflow from within a custom activity and attach some sort of reasonable error message? Should I just throw an exception, and if so is it just a generic exception or is there a specific one for aborting a workflow? Thanks, Rex
August 25th, 2010 4:30am

Hi Rex! You could either choose to end the workflow properly or simply throw an exception it's all up to you to decide how to treat it based on the circumstances - if you consider this an unexpected behavior you should raise an exception. There's a CancelWorkflowException in the Microsoft.ResourceManagement.Workflow.Runtime namespace you could use but it doesn't bring any extras compared to System.Exception. A good idea if throwing an exception from a workflow is to append a message to the Exception because that will be appended to the request. In your specific scenario it might be useful to store information about the different account names tried and for that I would use the UpdateRequestActivity that allows you to append values to the multi-value attribute RequestStatusDetail on the Request. //HenrikHenrik Nilsson, ILM/FIM MVP Blog: http://www.idmcrisis.com Company: Cortego (http://www.cortego.se)
Free Windows Admin Tool Kit Click here and download it now
August 25th, 2010 10:02am

Thanks. Can you point me to an code example that uses UpdateRequestActivity? There doesn't seem to be any usage documentation on it. It looks like you somehow manipulate the RequestStatusDetails property and then something happens?
August 25th, 2010 11:59am

I don't think there are any examples available but it's pretty straight forward. It has got a single static RequestStatusDetails property that allows you to set an array of RequestStatusDetail objects. The RequestStatusDetail class has the following members: DetailLevel (Enum - see below) EntryTime (DateTime) Message (String) These are the different available values in the DetailLevel Enum: Critical, Error, Warning, Information, Verbose //HenrikHenrik Nilsson, ILM/FIM MVP Blog: http://www.idmcrisis.com Company: Cortego (http://www.cortego.se)
Free Windows Admin Tool Kit Click here and download it now
August 25th, 2010 12:39pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics