How To Use If Package In Automation Anywhere

Introduction

This article describes how to use ‘If’ package in Automation Anywhere using community edition. In some circumstances, we need to do actions based on condition so I will explain the same in this article.

If you are a beginner then need to check this article Getting Started Robotic Process Automation using Automation Anywhere to create environment of Automation Anywhere.

Create a New bot

After logging Automation anywhere account through cloud community edition link,

How to use If package n Automation Anywhere

You will see a Dashboard as shown in below image and you can create a new bot through highlighted button ‘create a bot’,

How to use If package in Automation Anywhere

Bot Configuration

After clicking on ‘create a bot’ button, you will get a popup window. It will ask some information about bot which you want to create like-

  • Name of bot
  • Description of bot(optional)
  • Folder location of bot

How to use If package in Automation Anywhere

After clicking on choose option, a popup window will come where you can browse ‘CSharpCorner’ folder and click on choose to set a default location for your new bot.

How to use If package in Automation Anywhere

After creating bot, we will use ‘If’ package to calculate result based on percentage like-

  • >=75% : Pass with Distinction
  • >=33% and Above to < 75% : Only Pass
  • < 33% : Fail

And for this we will follow below steps-

  • Create Variables
    1. Create String Variable(To Store value after getting from user)
    2. Create Float Variable(To Store value after conversion)
  • Add Prompt for value(To get the value from user)
  • Convert String Variable To Number variable
  • Add If (>=75%) condition and show message ‘Pass with Distinction‘
  • Add else If (>=33% and Above to < 75% ) condition and show message ‘Only Pass’
  • Show message ‘fail’ message in else

Create Variables

Let’s create variables to store value after getting from user as string and after conversion as float.

Create String Variable

Create a variable through left side variable pane and click on ‘+’ sign, and select ‘String’ type and name as ‘StringVariable’ and click on create button.

How to use If package in Automation Anywhere

Let’s create another variable of ‘Number’ type with name as ‘NumberVariable’

How to use If package in Automation Anywhere

Add Prompt ‘for value’

Let’s go to ‘Action’ pane on left side and find ‘Prompt’ action. Drag & drop ‘for value’ into workspace and fill below details-

  • Caption of Prompt Window would be like ‘Get percenatge’
  • Prompt Message would be like ‘Please fill your Percentage’
  • Select ‘StringVariable’ to get prompt value.

How to use If package in Automation Anywhere

Convert ‘String’ to ‘Number’ Variable

In this step, we will convert ‘StringVariable’ into ‘NumberVariable’ and do so we go to ‘Action’ pane on left side and find ‘String’ action. Drag & drop ‘To Number’ into workspace and select ‘StringVariable’ as string & select ‘NumberVariable’ as ouput.

How to use If package in Automation Anywhere

Add ‘If’ condition for >=75%

In this step, we will add ‘if’ condition to check percentage >=75 and for that we will go to ‘Action’ pane on left side and find ‘If’ action. Drag & drop ‘If’ into workspace and fill below details-

  • Select ‘Number’ in condition because we are going to match number
  • Select ‘NumberVariable’ as source value
  • Select ‘Greater than or equal To(>=)’ as operator
  • Target Value will be 75

How to use If package in Automation Anywhere

Note: We will see in ‘else if’ section, how to add multiple condition over here through ‘AND’/’OR’.

Now, we will add ‘MessageBox’ through action pane to display message ‘Congratulations, You passed with Distinction!!’, if above condition fulfills.

How to use If package in Automation Anywhere

Add ‘If else’ condition for >=33% and Above to < 75%

Here, we will add ‘else if’ condition to check percentage >=33% and above to < 75 and for that we will again go to ‘Action’ pane on left side and find ‘If’ action. Drag & drop ‘else If’ into workspace and fill below details for both conditions with ‘and’ operator-

Condition-1

  • Select ‘Number’ in condition because we are going to match number
  • Select ‘NumberVariable’ as source value
  • Select ‘Greater than or equal To(>=)’ as operator
  • Target Value will be 33

Condition-2

  • Select ‘Number’ in condition because we are going to match number
  • Select ‘NumberVariable’ as source value
  • Select ‘Less Than(<)’ as operator
  • Target Value will be 75

How to use If package in Automation Anywhere

Now, we will add ‘MessageBox’ through action pane to display message ‘Congratulations, You passed!!’, if above condition fulfilled.

How to use If package in Automation Anywhere

Add ‘else’ for Fail

At last, we will add ‘else if’ condition and for that we will again go to ‘Action’ pane on left side and find ‘If’ action. Drag & drop ‘else’ into workspace.

How to use If package in Automation Anywhere

After that, we will add ‘MessageBox’ through action pane to display message ‘Sorry, You failed’.

How to use If package in Automation Anywhere

Where output will look like after running the bot.

  • >=75% : Pass with Distinction- Here we entered ‘85’ as percentage

How to use If package in Automation Anywhere

And we got the result as below based on ‘If’ condition,

How to use If package in Automation Anywhere

  • >=33% and Above to < 75% : Only Pass- Here we entered ‘45’ as percentage

How to use If package in Automation Anywhere

And we got the result as below based on ‘Else If’ condition-

How to use If package in Automation Anywhere

  • < 33% : Fail- At last, we entered ‘25’ as percentage

    How to use If package in Automation Anywhere

And we got the result as below based on ‘Else’ condition,

How to use If package in Automation Anywhere

Conclusion

In this article, how to use ‘If’ package in environment of Automation Anywhere.


Similar Articles