Passing integer to Javascript for Inject Javascript

How do I pass an integer to a Javascript as input parameter for Injeect Javascript activity?

Till now, we can pass parameters of Inject JS activity as a single string only.

To do integer operations, we need to accept parameters as string and then convert it to integer inside the JS code.

A script like below should work. If we pass the parameter as 37, it should return 47.

function addNumberWith10(e, a){
    var input = parseInt(a);
    var numberSum = input + 10;
    return numberSum.toString();

If we need to pass multiple parameters, we need to do a split within the JavaScript code because UiPath passes the parameter passed from activity as a single parameter.

If you note, I have returned the output value as string. This is another issue with UiPath. We can get output as integer if we use Inject JS activity with Internet Explorer. It will not work with Chrome.

See a bug I reported below.


Thanks Kannan, that’s what I originally did but thought there should be a direct way :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.