How To Execute Manual JavaScript In Automation Anywhere

Introduction

This article describes, how to execute manual JavaScript in Automation Anywhere using the community edition.

If you have a small piece of JavaScript code to run but don’t have knowledge of JavaScript, so no need to worry still you can execute that code. You just need to pass that JavaScript function name, input parameter (if any), and output parameter (if any) that’s it. So let’s begin this article.

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

Create a New bot

After logging Automation anywhere account through cloud community edition link,

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

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
  • Folder location of bot

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.

After creating bot, we will create 2 variables of string type, one for input parameter and second for output parameter.

Create Variable for Input and output Parameter

Let’s create a variable through left side variable pane and click on ‘+’ sign, After that fill the parameter name as ‘InputParameter’ and click on create button.

And do the same for output parameter with name as ‘Output Parameter’

Assign value to Input parameter

Now Go to ‘Action’ pane on left side and find ‘Assign’ from ‘String’ section (String->Assign). Drag & drop it on workspace and fill any text which you want to pass in JavaScript function as input parameter as I filled my name ‘Rahul Bansal’ over here.

Next just select ‘InputParameter’ as the destination variable to get text value.

Open JavaScript and Add manual JavaScript

Now Go to ‘Action’ pane on left side and find ‘JavaScript’ section. Drag & drop ‘Open’ into workspace. Select ‘Manual input’ radio button to fill JavaScript mentioned below,

function Print(name){
    return "Hello"+ name
}

Where ‘Print’ is function name and ‘name’ is input parameter. It returns a string after concatenation with input parameter.

Run JavaScript

Go to ‘Action’ pane on left side and find ‘JavaScript’ section. Drag & drop ‘Run Javascript’ into workspace. Enter name of JavaScript function named ‘Print’, Parameter as ‘InputParameter’ variable and output to variable as ‘OutputParameter’ variable.

Close JavaScript

Go to ‘Action’ pane on left side and find ‘JavaScript’ section. Drag & drop ‘Close’ into workspace to close JavaScript.

Message Box to Print Output Variable

Go to ‘Action’ pane on left side and find ‘Message box’ section. Drag & drop ‘Message box’ into workspace to display output variable. You need to just add title name as ‘Show JavaScript Output’ and select ‘OutputParameter’ in message to display.

Where output will be look like after running the bot.

Conclusion

In this article, how you can execute JavaScript function in environment of Automation Anywhere.