If-Else-Endif  - How to use                     Examples

This is one of the most powerful commands of Automation Anywhere. Use this to perform actions only if certain conditions are satisfied. Most of the conditional commands also offer a powerful & intelligent feature where you can specify how long to wait for this condition to be true.

  1. "If File exist" or "If File doesn't exist": Use this command when you want to perform action based on if certain file exist. For example if data file exist then you want to format that file and upload it to database.

  2. "If Folder exist" or "If Folder doesn't exist": This command is similar to above command, but it checks if a specific folder exists or not.

  3. "If Window exist" or "If Window doesn't exist": This command is probably one of the most frequently used commands. With this command you can check if certain application is open by checking for application window name, or if certain error condition occurred by checking for error window, or if file download has finished by checking for File download window and so on.

  4. "If Application running" or "If Application not running": If application is running but is not open (for example minimized to system tray) or an application that doesn't have a window but runs behind the scene then use this command.

  5. "If Script successful" or "If Script not successful": With this command you can integrate your legacy scripts of 3rd party scripts. This command will run the script and depending on return code decide if it was successful or not. If you already have developed scripts then use this to integrate them in Automation Anywhere.

  6. "If Task successful" or "If Task not successful"
    With this command you can integrate other Automation Anywhere task. This command will run the Automation Anywhere task and depending on return code decide if it was successful or not. For example if you have a script that monitors your website. If that script is successful that means your website is up and no action is required, but if website monitor script is not successful, it means website is down and then you can take other actions like sending email etc.

  7. "If Ping successful" or "If Ping not successful"
    Use this command to see if a machine or server is running. Based on result you can take appropriate actions.

  8. "If Variable"
    This simple looking command is probably the most powerful of all conditional commands. Actually it is many commands in one. With this command you can perform hundreds of checks. For example if you have copied anything from an application or website and you want to check if what you copied matches certain text, or if it is a number, is it greater than or less than some other variable or fixed number. You can do that all with this command.
  9. "If Web Control"
    If you want to check if a particular web control exists on a web page for e.g. a link or a textbox or a dropdown etc then use this command. This command will generally be used in the tasks using Web Recorder.
  10. "If File Size"
    If you want to check if a particular file is of certain size then use this command.
  11. "If File Date"
    If you want to check if a particular file is was created or modified on a certain date then use this command.
  12. "Image Recognition" (Available only in Enterprise version)
    Use this command to find if an image exists within another image either from a file or capture the rectangular area in any window. Specify the minimum percentage match that you want for the If command to be true. It also provides a very powerful feature whereby it allows you to click on the image if it is found within the larger image.

How long to wait for a condition to be true?

Most of the conditional commands offer a powerful feature where you can specify how long to wait for this condition. Let's say you want to perform some action only if a window exists. You know it might take anytime between 5 seconds to 5 minutes for that window to come up.

  1. Obviously, you would not like to wait for 5 minutes if the window comes up in 30 seconds.
  2. Automation Anywhere takes care of this for you.
  3. In the textbox in the If command, specify the maximum time (in seconds) up to which you like to wait for the window to appear. In this case 5 minutes i.e. 300 seconds.
  4. Automation Anywhere will keep on checking for the window up to 300 seconds and as soon as the window appears, will execute actions within the conditional commands. So in this case, it will wait only 30 seconds and then performs the actions.
  5. If you leave the textbox empty or provide 0 then Automation Anywhere checks the condition right away and if it is met it will execute the actions otherwise it will skip those actions and proceed to actions after Endif.