How to implement Decision Action in .net

I want to write an action that, depending on its result, either runs its child actions or skips them. I have searched in every documentation that I found, but I just could not figure out how to implement the Decision Action type in .NET.

Best regards,
Robin

Hi Robin

Before you go down the path of creating custom actions, are you sure you cannot do what you need with the built in actions?

Things to investigate :

  • Execute Program action - the result of action can be stored in a variable, which can then be used with an If…Then action to determine whether to execute child actions.

  • Run Script Action - which can set Automise variables (ATVariables.Variable or ATVariables[“name”] depending on the language) - again paired with the If…Then action.

To create a decsion action in .net you just create a regular standard action - the result of the Execute method determines if the child actions will run or not. If you want to fail the action then throw an exception.

Hi Vincent,

Thanks for the fast response. I have written a custom action that interacts with the RestAPI of a device, and when setting the action type to ‘standard action,’ it runs just fine. Currently, I am using the result of the action for control flow with an ‘If previous action failed’ after it. Now, when I set the action type to ‘Decision Action’ and try to run it, I get a validation error, even though when debugging and setting a breakpoint in the validation part of the code, it never reaches it, the error in automise is shown in the picture.
grafik

Best regards,
Robin

Hi Robin

The validation error is a bug - I was able to reproduce that here. When I turn validation off (options\Automise\validation) the action works - mostly.

I say mostly because it appears error handling is broken - throwing an exception just makes the decision false and doesn’t actually fail the action. I will look into whether that can be fixed without any api changes.

Either way we’ll upload a new build with at least the validation fix once further investigation is completed.

This build fixes the validation issue and also allows errors thrown in the action to fail the action.

https://downloads.finalbuilder.com/downloads/automise/500/AT500_1539.exe
https://downloads.finalbuilder.com/downloads/automise/500/ATCMD500_1539.exe
https://downloads.finalbuilder.com/downloads/automise/500/AutomiseRunner500_1539.exe