RPA challenge - pass data from Excel as parameters into ExecuteJavascript

  • 56 Views
  • Last Post 3 weeks ago
RepCat posted this 4 weeks ago

For the challenge, we download an Excel file, extract the data, and then fill in fields on a certain number of pages.

In other languages (Python, Autohotkey for example) I can get very good speed (under 200ms) for the challenge, without errors, by filling the fields from a Javascript array.  We can get similar results with Intellibot.

We download the table to the filesystem with HTTP -> DownloadFile ("challenge.xlsx").

The table looks like this in Excel:

Here is a PNG of the flow:

Using JSON -> SerializeObject we get this string:

[{"First Name":"John","Last Name ":"Smith","Company Name":"IT Solutions","Role in Company":"Analyst","Address":"98 North Road","Email":"jsmith@itsolutions.co.uk","Phone Number":"40716543298"},{"First Name":"Jane","Last Name ":"Dorsey","Company Name":"MediCare","Role in Company":"Medical Engineer","Address":"11 Crown Street","Email":"jdorsey@mc.com","Phone Number":"40791345621"},{"First Name":"Albert","Last Name ":"Kipling","Company Name":"Waterfront","Role in Company":"Accountant","Address":"22 Guild Street","Email":"kipling@waterfront.com","Phone Number":"40735416854"},{"First Name":"Michael","Last Name ":"Robertson","Company Name":"MediCare","Role in Company":"IT Specialist","Address":"17 Farburn Terrace","Email":"mrobertson@mc.com","Phone Number":"40733652145"},{"First Name":"Doug","Last Name ":"Derrick","Company Name":"Timepath Inc.","Role in Company":"Analyst","Address":"99 Shire Oak Road","Email":"dderrick@timepath.co.uk","Phone Number":"40799885412"},{"First Name":"Jessie","Last Name ":"Marlowe","Company Name":"Aperture Inc.","Role in Company":"Scientist","Address":"27 Cheshire Street","Email":"jmarlowe@aperture.us","Phone Number":"40733154268"},{"First Name":"Stan","Last Name ":"Hamm","Company Name":"Sugarwell","Role in Company":"Advisor","Address":"10 Dam Road","Email":"shamm@sugarwell.org","Phone Number":"40712462257"},{"First Name":"Michelle","Last Name ":"Norton","Company Name":"Aperture Inc.","Role in Company":"Scientist","Address":"13 White Rabbit Street","Email":"mnorton@aperture.us","Phone Number":"40731254562"},{"First Name":"Stacy","Last Name ":"Shelby","Company Name":"TechDev","Role in Company":"HR Manager","Address":"19 Pineapple Boulevard","Email":"sshelby@techdev.com","Phone Number":"40741785214"},{"First Name":"Lara","Last Name ":"Palmer","Company Name":"Timepath Inc.","Role in Company":"Programmer","Address":"87 Orange Street","Email":"lpalmer@timepath.co.uk","Phone Number":"40731653845"}]

Inside our ExecuteJavascript activity we see this:

Here is the code for easier copying and pasting:

var myArray = eval(jsonIn);
// alert(myArray[0]["Last Name "]);
var start = document.querySelector('button.waves-effect');
start.click(); 
var i;
for (i = 0; i < 10; i++) {
document.querySelector('input[ng-reflect-name="labelEmail"]').value = myArray[i]["Email"];
document.querySelector('input[ng-reflect-name="labelAddress"]').value = myArray[i]["Address"];
document.querySelector('input[ng-reflect-name="labelFirstName"]').value = myArray[i]["First Name"];
document.querySelector('input[ng-reflect-name="labelLastName"]').value = myArray[i]["Last Name "];
document.querySelector('input[ng-reflect-name="labelPhone"]').value = Math.trunc(myArray[i]["Phone Number"]);
document.querySelector('input[ng-reflect-name="labelRole"]').value = myArray[i]["Role in Company"];
document.querySelector('input[ng-reflect-name="labelCompanyName"]').value = myArray[i]["Company Name"];
document.querySelector('input[value="Submit"]').click();
}

 Here are the results on Win10, very modest commodity hardware:

Best regards and good luck,
RepCat

 

 

Order By: Standard | Newest | Votes
Intellibot Support posted this 4 weeks ago

Hi,

Great post, good to see that you have explored our wide variety of components. Thanks for the automation and results.

 

Thanks & Regards,
Intellibot Support.

 

 

  • Liked by
  • admin@repcat.cat
kushang@intellibot.io posted this 3 weeks ago

@RepCat Since your excel file has table data, you can directly use the Data Reader - ReadFromExcel component to read the complete worksheet data as a table. Simply pass the output to the 'JSON Serialize' component to get the same result. 

This will eliminate a few steps, and complete the automation faster

Regards

K

  • Liked by
  • admin@repcat.cat
RepCat posted this 3 weeks ago

@kushang@intellibot.io, thanks, you are right about the redundant steps. Although I haven't followed your example directly in the first example, this does significantly speed up execution. An alternative that more closely follows your example is shown below this one. I can see there are many approaches one could follow to get to the same place, using Data Reader activities, Excel connector activities, or both.

Alternative:

Best regards,
RepCat

Close