Skip to main content
Question

How to Reference an RPA Variable in the Run Javascript Action with Manual Input?

  • December 27, 2024
  • 2 replies
  • 67 views

Forum|alt.badge.img+2

Hi all,

I’m Darshan Hiranandani, trying to use the "Run Javascript" action in Automation Anywhere with manual input, but I need to reference an RPA variable within the JavaScript code.

For example, I have a variable $variableInRPA$ (which holds a value like 50), and I want to add 10 to it in the JavaScript code, then return the result. Here's what I’ve been attempting:

(function(){
    var variableInManualInput = $variableInRPA$;
    var result = variableInManualInput + 10;
    return result;
}());

Is there a way to pass the RPA variable into the JavaScript code correctly? I’m unsure how to reference it properly for this use case.

Has anyone encountered this before and figured out a solution? Any tips or suggestions would be greatly appreciated!

Thanks in advance!

Regards

Darshan Hiranandani

2 replies

Aaron.Gleason
Automation Anywhere Team
Forum|alt.badge.img+10
  • Automation Anywhere Team
  • 541 replies
  • December 27, 2024

You cannot. One is a client side scripting language, one is a server side language. 

What you can do is to have your automation write dynamic JavaScript with the values of the variables. This can be done with the Log Text To File action (to write it to a file) or carefully concatenating a string variable with the JavaScript contents inside.


Forum|alt.badge.img+5
  • Navigator | Tier 3
  • 36 replies
  • December 28, 2024

Check out the following thread: How to reference multiple variables in javascript to get a output | Community

The question in that thread asks about passing multiple variables to a JavaScript function, but you could apply the same logic to pass a single variable to your JavaScript code.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings