API
Version 7.x > API > Proper way to handle a custom Workflow Action that fails View modes: 
User avatar
Certified Developer v6
Certified Developer v6
Dave - 5/1/2013 9:43:45 AM
   
Proper way to handle a custom Workflow Action that fails
Hi,

I have a custom Workflow Step/Action that calls to a third-party REST API. I'm not sure how to handle the scenario when the REST API call fails. I don't want to advance the workflow in this case. I believe I want to "reject" it back to the last step that allows approval/rejection. Do you have any guidance you can provide?

Thanks,
Dave

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 5/14/2013 5:48:13 AM
   
RE:Proper way to handle a custom Workflow Action that fails
Hi Dave,

I have discussed it with our developers, but your requirement is not clear enough.

You have to use an Advanced workflow if you want to handle custom steps. The third-party API should also return some value, right? I would recommend you to take a look at the following blog post: How to Create Custom Workflow Action.
Especially:
Arguments.StopProcessing = true;
using (WorkflowActionContext ctx = new WorkflowActionContext() { CheckStepPermissions = false })
{
Arguments.Comment += string.Format(" | Document needs approval also from these manager(s): {0}", missingManagers.Join(", "));
WorkflowManager.MoveToSpecificStep(Node, Arguments.OriginalStep, Arguments.Comment, WorkflowTransitionTypeEnum.Automatic);
}

with stopprocessing - you will stop the processing of request and using MoveToSpecificStep you can forward it where you need.

Best regards,
Martin Danko

User avatar
Certified Developer v6
Certified Developer v6
Dave - 5/14/2013 8:49:03 AM
   
RE:Proper way to handle a custom Workflow Action that fails
Thanks Martin!

This is exactly what I was looking for. Arguments.StopProcessing = false did the trick, then I used WorkflowManager.MoveToPreviousStep.

Thanks!
Dave

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 5/14/2013 9:25:12 AM
   
RE:Proper way to handle a custom Workflow Action that fails
Hi Dave,

No problem.. I'm very happy that we've hit it on the first shot! Partialy it was just a guess.
You're welcome and thank you for a very nice response.

Best regards,
Martin Danko