Inject JS InputParamter

studio

#1

How to access InputParameter of inject JS in javascript file. Value of declared variable in studio is not accessible configured js file.
InputParameter declared in injectJS component configure on textbox on webpage : InputParamFC
Javascript Used :
function(InputParamFC) {
var obj = InputParamFC
alert(‘Called:-’ + obj.value)
var userinput = document.getElementsByName(‘Username’)[0].value;
return userinput;
}


#2

Do you mean this way?


#3

Just for your reference find this attached sample workflow and let me know :slight_smile:

js-parameter-pass-sample.zip (2.1 KB)


Regards…!!
Aksh


How to pass input parameter in Inject java script
#4

Thanks Aksh,

With second parameter i am able to read input variable declared in studio from my javascript file.
Would be also helpful if you can help to understand what is the purpose of first parameter as in some sample scenarios fro use.

Best Regards,
Kshitij


#5

e is just a parameter name and it is a reference for event object which will be passed to event handlers.you can use any variable name here instead of e as well. It allows us to prevent the propagation of default behaviors for certain elements.

For better understanding, visit this link: Demo

Mouse Events DEMO uses e.which and e.type

Regards…!!
Aksh


#6

Hi aksh,
I am also looking for the solution of the same scenario. I wanted to pass a value from uipath to jquery/javascript function and that value is inturn used in js code. I have downloaded the sample and tried to execute the same. I didnt understand which screen should be indicated in that injectjs script activity. I am getting the following error “Inject js script ‘DIV ember747’ : Value does not fall within the expected range.” Could you please help me in resolving this.


#7

indicate that screen on which you wants to execute this js code. here i have used Google Chrom browser screen. you can easily check that in its selector property.

and Don’t have latest studio version it has been fixed or not but Inject js script gives some error with my IE but on the other hand it works well in chrome.

Regards…!!
Aksh


#8

Hi @aksh1yadav
Just a query,
In case the javascript function has multiple input parameters, how would we be passing those multiple inputs to Inject Js activity?
Thanks,


#9

Hey @qwerty123

If you have noticed Inject Js activity InputParameter Property only will take string as a parameter.

So There is one way from my side is declare your variables and then pass it like variable1+","+variable2…

and split this in js and access the variables with array index.

You will understand the above with attached sample for you.

js-parameter-pass-sample_with mulitple_parameters.zip (2.3 KB)

Regards…!!
Aksh


#10

Thanks alot!
Will go through your sample.


#11

@ThieuDV


#12


i am getting exception