cancel
Showing results for 
Search instead for 
Did you mean: 

IF Else Statement

DianaPalmer
Level 2
How do you write an IF else statement as an expression in Blueprism.  I want to use the calculation stage to determine if one date is earlier than the other, then I will use the earlier date and store the earlier date in a data item.
12 REPLIES 12

AmiBarrett
Level 12
Without a code stage, this would need to be done using either a Decision or a Choice stage. if x=y    Do code else    Do other code Would look like [Decision] x=y Yes    Do code No    Do other code   You could also have if x=y    Do code block 1 else if x=z    Do code block 2 else    Do other code Which would look like [Choice] x=y    Do code block 1 x=z    Do code block 2 Otherwise    Do other code

DianaPalmer
Level 2
I am not familiar with the code stage. Do you have any documents you can send to me so I can read about how to use it.

AmiBarrett
Level 12
It's an option that is only available from an object, and not from a process. However, a process can call an object. In the initialize page for an object, you can click the stage containing the page name. This will allow you to choose the language (C#, VB, J#), as well as enter global code and add .dll files & namespaces that can be referenced through the whole object. On any action you create within that object, you can place a code stage, which will compile and execute whatever code you write. I recommend poking through some of the utility objects such as Collection Manipulation (or Collections, I've seen it labeled both ways) to get a feel for how it works.

DianaPalmer
Level 2
Thank you  

Hi Ami,
Are there any plans to add Immediate If (iif) to the expressions? That sure would simplify many things.

------------------------------
Kevin Miller
------------------------------

Hi @KevinMiller,

As far as I know, there are no plans to add support for a ternary conditional operation as a native function within the Calculation stage. Within a process/VBO flow you can replicate the basic capability though by using a regular Decision stage and two Calculation stages as depicted below.

21570.png
You can also use the IIF (VB.NET) or ?: (C#) features within Code stages. 

Cheers,

------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

There is a workaround :

 

Replace( Replace( {Condition} ;

True;  {CommandIfTrue} );

False; {CommandIfFalse} )

-------------------------------------------

Original Message:
Sent: 2/24/2022 1:41:00 PM
From: Kevin Miller
Subject: RE: Without a code stage, this…

Hi Ami,
Are there any plans to add Immediate If (iif) to the expressions? That sure would simplify many things.

------------------------------
Kevin Miller
------------------------------

Nice idea @Johan Michiels!. For anyone that's interested, here's an example of how this looks in a Collection stage. In this example, the input data item Test Value is a Number set to 1. Running over this Calculation stage results in the output This is a True value. being output. If you were to change the value of Test Value to say -1 you would get This is a False value. as output.

21571.png
Cheers,

------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

Hi Diana,

You can use the If Else Statement using Decision Stage in Blue Prism. Screenshot attached below
21572.jpg
21573.jpg


------------------------------
Vikash Anand
Application Development Senior Analyst
Accenture
------------------------------