Set arguments from a datatable

Hi everyone,
I am quite new with UIPath and I need some help to solve a problem for work.
I have to fill fields in the first picture using the Excel file in the second one, in particular I’d like to know how to set arguments in the argument panel. For example, how can I choose the first couple?
Thanks.

Kind regards,
Martina


Hi! you can use variables to fill the data.

1.read the excel using read range output as dt
2.for each row pass the output as dt
3. crate one variable UserName=CurrentRow(“username”).ToString
4.create one more variable for password Password=CurrentRow(“password”).ToString
5.and take one type into indicate it on screen and pass the UserName variable
6.Take one more type into and pass the Password variable
7. just use the click activity and indicate it on accedi.

Note: Check the selectors for every activity which you indicated

if you wants do it with arguments have a view on this thread

Regards,
NaNi

Ok, but how can I choose the first couple, instead of the second, using variable, for example?
Thanks a lot.

Martina

Hi @martina.cavalieri ,

First of all storing credentials in the excel is not best practice. please store your credentials in the orchestrator as credentials asset with the name as username you mentioned in the excel file.

→ using Get credential activity to retrieve the username and password from the orchestrator. input parameter will be Asset name(i.e username in our scenario) and output will be username and password from the orchestrator.

->To input the key name(username). the excel should have only usernames not passwords. All the usernames we have to read by using read range activity and store into data table. use for each row activity to loop the usernames one by one and get the specific credentials and enter the username and passwords to the application you mentioned.

Regards,
Kirankumar.

May i know what is the first couple? you mean to say first row?

if yes In for each row this will iterate every row. so according to your input data which is there inside the excel. this will fill from first row to last row. by using this

.

Regards,
NaNi

If you specifically want to target a ‘couple’ from the excel you can try:

Read Cell and target the specific cell you want

Or, stull using read range, and analysing the datatable:
yourDT.rows(1)(“username” )
This will directly give you the username of the 2nd row. (the index counter in the expression starts at 0).
If you have to process the entire list better to use the for each row example in the previous posts.

If your use case it to consult the excel for credentials to log in to an application… indeed store the credentials in the credential vault instead of using excel. Your excel document is every hacker’s wet dream…

Hi!
I’m sorry, but I am not allowed to use Orchestrator for now and I was asked to work with datatable in this test case.
Thanks.

Regards,
Martina

ok got it. thanks.

Regards,
Kirankumar.

Yes, I meant the first row, but I don’t need the iteration for each one: I’d like to know how I can set specified credentials in the datatable in variable panel according to the test case I need to run in that moment.
Thanks.

Hey!

if you wants to use only first rows. no need to read excel just do the follow.

1.Take one type into and indicate it on UserName field and just pass the string like this “unxqtv1”.
2.Take one more type into activity indicate it on password field and pass the string like this “gr0upama”.
3.Take one click activity and indicate it on Accedi. you will successfully log in to the page.

no need to create the variables in this case.

Regards,
NaNi

It’s fine, but I was asked to use an Excel file.
Thanks.

Hi Martina,

If you only want the first row credentials if I understand correctly from data table, you can simply use : <Datatable_Variable>.Rows(<row_number>)(column_index>).ToString

Here, <Datatable_Variable> will be the name of your datatable variable as you can see in the variable panel.
<row_number> will be starting from 0 to N-1. It means if first row, then use 0 here.
<column_index> will be starting from 0 to N-1. It means if first column, then also use 0 here.

For example if you want the first pair of credentials, create two variables username and password and set the values using Assign activity as:

Suppose the datatable name is dtTest, then

username = dtTest.Rows(0)(0).ToString
password = dtTest.Rows(0)(1).ToString

Hi!
I used “Excel Application Scope”, put file path in, then “Read Range” with the sheet name I have to use, create DataTable variable as “dtCredentials”, strUsername=dtCredentials.Rows(4)(0).ToString, strPassword=dtCredentials.Rows(4)(1).ToString, but when I run it I have this error message:

Thanks.

Make sure your read range starts at the correct point of the excel.
If your data is

  • in another tab
  • starts at a cell other than “A1”
    it might not fetch the data correctly. Use the debugging tools to validate if the read range actually populated your datatable with the correct input.
1 Like