if
Summary
This Action returns values that fits the condition.
Description
The IF statement executes a statement if a specified condition is truthy.
If the condition is false, another statement in the optional ELSE-IF clause will be executed.
Fields
In IF Action there are 3 type fields.
- IF : To check condition
- return : Return result If the condition is True
- ELSE-IF : Add more IF condition
![Version Location](/ent/assets/images/01_if-f18d8d8450c2138576f0eccf7912955f.png)
- IF
This field is to check If condiion.
Basically, default is 'Boolean Type'.
Also, you can change the type to 'References Data', 'Action', 'Condtions', 'Comparisons' like below.
![Version Location](/ent/assets/images/02_if-2e19a967263fcd523729796d80001bbe.png)
- return
This field determines how to return the value that returns when the if statement is true.
You can change the type to 'Values (string, number...)', 'References Data', 'Action' ...' like below.
![Version Location](/ent/assets/images/03_if-8cdbeeb194678ff51f83722ca585c086.png)
- Add ELSE-IF
This field to use when you want to add more if statements.
Click to add more else-if statements, as shown below.
![Version Location](/ent/assets/images/04_if-49a68034d1ab4d0d5c9da4b016fc1bf9.png)
If you add Else-if and set the boolean true value in ELSE-IF field,
the return value can be set to a value that comes out as default in the if statement.
Example
Let's See how to use IF Action!
Using Comparisons
Let's imagine.
I want to make an if statement true only when data with reference data is data that meets the criteria I set.
We will put the string 'Autoflow'
in the ref_data
,
the value to true
only if the ref_data
coming through the if statement is 'Autoflow'
.
We will get Action result like below.
- If condition is
true
, it would returnTrue Result!
- If condition is
false
, it would returnFalse Result!
1. Prepare Reference Data
We will make Reference Data by 'Variable/set Action'
I just add value
as String, then I put 'Autoflow'
in value.
Then I changed OUTPUT
's name to 'ref_data'
![Version Location](/ent/assets/images/05_if-7bf4d72e3a958aa83017964c637d9730.png)
2. Change IF Action's Conditon.
I just Click 'boolean'
in IF field, Then Click 'equal'
![Version Location](/ent/assets/images/06_if-6045e56c01a55c9ee55fbd48935fba13.png)
Then Click 'number'
in IF field.
![Version Location](/ent/assets/images/07_if-75854504d577f69c274c8e75908fc19a.png)
Then Click 'data'
button.
![Version Location](/ent/assets/images/08_if-059c0fd9b4f2361c71ff582d434d1cf9.png)
Change Scope and Path as variable > ref_data
![Version Location](/ent/assets/images/09_if-338351643bf4303bb597833de258b499.png)
Then Click 'number'
in IF field.
![Version Location](/ent/assets/images/10_if-cd4488278fc1a38fe981aba211677c9e.png)
Then Click 'string'
![Version Location](/ent/assets/images/11_if-fa02022b3138191d57f5ad6d41a4997d.png)
We are ready to Comparison to use IF Action now! 👏
![Version Location](/ent/assets/images/12_if-def0d2638ea9ee5befbc49be2788aeab.png)
3. Setting return
field.
Click null
in return field, then click string
![Version Location](/ent/assets/images/13_if-8e393bfe1f6eb3014210bce5c744c35b.png)
Write True Result!
in return field in string
,
Then click Add ELSE-IF field to add default
![Version Location](/ent/assets/images/14_if-7ffe666316d54080528113d89da4693e.png)
Write False Result!
in return field in string
,
![Version Location](/ent/assets/images/15_if-525b8a1c41d6e7f03932e12aae203b46.png)
We are ready to get result to use IF Action now! 👏
4. Get a result by using Simulation
!
Start Simulation, then See the result! 👀
You don't know how to use Simulation
in Autoflow?
Then, Click here! 🔗
![Version Location](/ent/assets/images/16_if-f23cb1a73256ffb763c371a59c8cff62.gif)
I put comparison string to Autoflow
and ref_data
is Autoflow
.
That means I will get True
result from IF
Action.
Now we can see True Result!
in Action output.👀
![Version Location](/ent/assets/images/17_if-c60d6fe16787ca74b838c033250c6881.png)
I put comparison string to eric
and ref_data
is Autoflow
.
That means I will get False
result from IF
Action.
Also we can see False Result!
in Action output.👀
![Version Location](/ent/assets/images/18_if-48f9af1d872729c628baa147420db96a.png)