# How to implement Decision Action in .net

**URL:** <https://www.finalbuilder.com/forums/t/how-to-implement-decision-action-in-net/7419>\
**Category:** Discussion\
**Created:** [October 30, 2023, 10:11pm UTC](https://www.finalbuilder.com/forums/t/how-to-implement-decision-action-in-net/7419 "2023-10-30T22:11:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AutomiseUser](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/6bbea6/32.png) [@AutomiseUser](https://www.finalbuilder.com/forums/u/AutomiseUser)\
**Post date:** [October 30, 2023, 10:11pm UTC](https://www.finalbuilder.com/forums/t/how-to-implement-decision-action-in-net/7419/1 "2023-10-30T22:11:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)\
**Post date:** [October 30, 2023, 10:37pm UTC](https://www.finalbuilder.com/forums/t/how-to-implement-decision-action-in-net/7419/2 "2023-10-30T22:37:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AutomiseUser](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/6bbea6/32.png) [@AutomiseUser](https://www.finalbuilder.com/forums/u/AutomiseUser)\
**Post date:** [October 31, 2023, 7:33am UTC](https://www.finalbuilder.com/forums/t/how-to-implement-decision-action-in-net/7419/3 "2023-10-31T07:33:35Z")

</div>

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](https://www.finalbuilder.com/forums/uploads/default/original/2X/7/7392381d73808c7f7e78105aadfd7ba009b0b135.png)

Best regards,  
Robin

---

<div class="post-metadata">

**Author:** ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)\
**Post date:** [October 31, 2023, 8:07am UTC](https://www.finalbuilder.com/forums/t/how-to-implement-decision-action-in-net/7419/4 "2023-10-31T08:07:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)\
**Post date:** [October 31, 2023, 9:21pm UTC](https://www.finalbuilder.com/forums/t/how-to-implement-decision-action-in-net/7419/5 "2023-10-31T21:21:42Z")

</div>

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/AT500_1539.exe)  
[https://downloads.finalbuilder.com/downloads/automise/500/ATCMD500\_1539.exe](https://downloads.finalbuilder.com/downloads/automise/500/ATCMD500_1539.exe)  
[https://downloads.finalbuilder.com/downloads/automise/500/AutomiseRunner500\_1539.exe](https://downloads.finalbuilder.com/downloads/automise/500/AutomiseRunner500_1539.exe)
