Searching a value in CSV then fill a form.
Forum rules
iMacros EOL - Attention!
The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely,
The Progress Team
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
iMacros EOL - Attention!
The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely,
The Progress Team
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Searching a value in CSV then fill a form.
Hello.
I would love to know if a macro could search a CSV file for a specific value and when it founds one then it gets all other data for a form to fill.
Example.
COL1____COL2_____COL3
One______A _______B
Two _____B_______C
When the macro finds for example the word "One" it gets the A and B and fills the apropirate fields.
I would really appriciate some direction for solution.
I would love to know if a macro could search a CSV file for a specific value and when it founds one then it gets all other data for a form to fill.
Example.
COL1____COL2_____COL3
One______A _______B
Two _____B_______C
When the macro finds for example the word "One" it gets the A and B and fills the apropirate fields.
I would really appriciate some direction for solution.
Re: Searching a value in CSV then fill a form.
Please could I get some answer to it if it is possible or not?
Re: Searching a value in CSV then fill a form.
Good question, interested to know aswell!Daivana wrote:Please could I get some answer to it if it is possible or not?
-
- Posts: 3834
- Joined: Mon May 31, 2010 4:59 pm
Re: Searching a value in CSV then fill a form.
Hello,
The most efficient way would be to write a Javascript to process the file and search for the value yourself. Or, you could use the following script and macro code to sequentially search through the file looking for the value, although this will be much slower for larger files.
LoopFile.iim:
The most efficient way would be to write a Javascript to process the file and search for the value yourself. Or, you could use the following script and macro code to sequentially search through the file looking for the value, although this will be much slower for larger files.
Code: Select all
var ret;
try
{
checkErr(iimPlay("CODE:PROMPT Please<SP>enter<SP>the<SP>search<SP>value: !VAR1\nSET !EXTRACT {{!VAR1}}"));
var searchVal = iimGetLastExtract(1);
var currentVal;
var row = 2; // Start with row 2 to skip header row
while (true)
{
checkErr(iimSet("row", row));
ret = iimPlay("LoopFile");
if (ret == -951) // Check for EOF
{
checkErr(iimSet("searchVal", searchVal));
checkErr(iimPlay("CODE:PROMPT {{serachVal}}<SP>was<SP>not<SP>found<SP>in<SP>CSV<SP>file!"));
break;
}
checkErr(ret); // Check for other errors
currentVal = iimGetLastExtract(1);
if (currentVal == searchVal)
{
checkErr(iimSet("row", row));
checkErr(iimPlay("FillForm"));
break;
}
row++;
}
}
catch (e)
{
alert(e.toString() + ": " + iimGetLastError());
}
function checkErr(retCode)
{
if (retCode < 0)
{
throw retCode;
}
return;
}
Code: Select all
SET !DATASOURCE Address.csv
SET !DATASOURCE_COLUMNS 8
SET !DATASOURCE_LINE {{row}}
SET !EXTRACT {{!COL1}}
Regards,
Tom, iMacros Support
Tom, iMacros Support
Re: Searching a value in CSV then fill a form.
I am really thankful for the help, I know that easier is to make a javascript for the job without imacro.
I am trying to understand how the code works, everything is fine but the script wont find the value in csv file, I tried to tinker a little the both scripts but no avail.
I want to know this peace of code
the FillForm.iim is for example where to put the imacro script for filling my form?
----------------------
This is solved
I am trying to understand how the code works, everything is fine but the script wont find the value in csv file, I tried to tinker a little the both scripts but no avail.
I want to know this peace of code
Code: Select all
if (currentVal == searchVal)
{
checkErr(iimSet("row", row));
checkErr(iimPlay("FillForm"));
break;
}
----------------------
This is solved
Last edited by Daivana on Thu Nov 04, 2010 3:04 pm, edited 1 time in total.
Re: Searching a value in CSV then fill a form.
The script is working just fine, but I would like to have some help.
When I execute the javascript I have to tipe what I am searching for, but how would I make that the script, when executed, searches for a value when it is tipped allready in a field.
Right now it just fills values from one row, but how should it get the second row value?
The script for now is:
The js I had been provided.
LoopFile.iim
And the Fill form script.
So I would know how to get the value from second row and fill the field, could be I am missing a thing, what peace of code?
I know that in the javascript the is something like loop or adding + one value or step to the next value, but I dont really understand how to get the other value.
Please an answer would help
When I execute the javascript I have to tipe what I am searching for, but how would I make that the script, when executed, searches for a value when it is tipped allready in a field.
Right now it just fills values from one row, but how should it get the second row value?
The script for now is:
The js I had been provided.
Code: Select all
var ret;
try
{
checkErr(iimPlay("CODE:PROMPT Please<SP>enter<SP>the<SP>search<SP>value: !VAR1\nSET !EXTRACT {{!VAR1}}"));
var searchVal = iimGetLastExtract(1);
var currentVal;
var row = 1; // Start with row 2 to skip header row
while (true)
{
checkErr(iimSet("row", row));
ret = iimPlay("LoopFile");
if (ret == -951) // Check for EOF
{
checkErr(iimSet("searchVal", searchVal));
checkErr(iimPlay("CODE:PROMPT {{searchVal}}<SP>was<SP>not<SP>found<SP>in<SP>CSV<SP>file!"));
break;
}
checkErr(ret); // Check for other errors
currentVal = iimGetLastExtract(1);
if (currentVal == searchVal)
{
checkErr(iimSet("row", row));
checkErr(iimPlay("GLPIFIller"));
break;
}
row++;
}
}
catch (e)
{
alert(e.toString() + ": " + iimGetLastError());
}
function checkErr(retCode)
{
if (retCode < 0)
{
throw retCode;
}
return;
}
Code: Select all
SET !DATASOURCE Address.csv
SET !DATASOURCE_COLUMNS 5
SET !DATASOURCE_LINE {{row}}
'PROMPT {{!COL1}}
SET !EXTRACT {{!COL1}}
Code: Select all
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:form_ticket ATTR=NAME:track_data1 CONTENT=
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:form_ticket ATTR=NAME:track_data2 CONTENT={{row}}
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:form_ticket ATTR=NAME:track_data3 CONTENT={{row}}
I know that in the javascript the
Code: Select all
row++;
Please an answer would help