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.