Filter a table

Discussions and Tech Support specific to the iMacros for Chrome extension.
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
Post Reply
gonzalo.moraga
Posts: 7
Joined: Thu Nov 30, 2017 1:55 pm

Filter a table

Post by gonzalo.moraga » Thu Nov 30, 2017 2:06 pm

Hi! I have a big table divided in several pages. The table has an attribute named tracking code that has an input field on the top so you can filter and only show the row that you want. Then each row has buttons in the right, so i want a loop to filter the table following a list of tracking codes that i have in a csv file, and then press a button of the row that is named 'R'. I have the following piece of code

VERSION BUILD=5301016 RECORDER=CR
'Uses a Windows script to submit several datasets to a website, e. g. for filling an online database
TAB T=1
' Specify input file (if !COL variables are used, IIM automatically assume a CSV format of the input file
'CSV = Comma Separated Values in each line of the file
SET !DATASOURCE archivoPrueba.csv
URL GOTO=http://wms.linio.cl/adm/list-awaiting-shipment.php
SET !LOOP 1
'Increase the current position in the file with each loop
SET !DATASOURCE_LINE {{!LOOP}}
' Fill web form
TAG POS=3 TYPE=INPUT:TEXT ATTR=ID:pedido CONTENT={{!COL1}}
TAG POS=1 TYPE=BUTTON ATTR=TXT:R

But whats happening is that the table is not filtering the rows, so the macro is always pressing the 'R' button of the first row. However, when i fill the input field manually, i can filter the table. Please some help! I've been an entire day trying to fix this :(
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Filter a table

Post by chivracq » Thu Nov 30, 2017 2:40 pm

gonzalo.moraga wrote:Hi! I have a big table divided in several pages. The table has an attribute named tracking code that has an input field on the top so you can filter and only show the row that you want. Then each row has buttons in the right, so i want a loop to filter the table following a list of tracking codes that i have in a csv file, and then press a button of the row that is named 'R'. I have the following piece of code

Code: Select all

VERSION BUILD=5301016 RECORDER=CR
'Uses a Windows script to submit several datasets to a website, e. g. for filling an online database
TAB T=1     
' Specify input file (if !COL variables are used, IIM automatically assume a CSV format of the input file
'CSV = Comma Separated Values in each line of the file
SET !DATASOURCE archivoPrueba.csv
URL GOTO=http://wms.linio.cl/adm/list-awaiting-shipment.php
SET !LOOP 1
'Increase the current position in the file with each loop 
SET !DATASOURCE_LINE {{!LOOP}}
' Fill web form   
TAG POS=3 TYPE=INPUT:TEXT ATTR=ID:pedido CONTENT={{!COL1}}
TAG POS=1 TYPE=BUTTON ATTR=TXT:R
But whats happening is that the table is not filtering the rows, so the macro is always pressing the 'R' button of the first row. However, when i fill the input field manually, i can filter the table. Please some help! I've been an entire day trying to fix this :(
(F)CIM...! :mrgreen: (Read my Sig...)

It doesn't look like it but you happened to have selected the correct Sub-Forum by "Chance", and that's a "Hint" in the direction for the probable Solution... :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
gonzalo.moraga
Posts: 7
Joined: Thu Nov 30, 2017 1:55 pm

Re: Filter a table

Post by gonzalo.moraga » Thu Nov 30, 2017 3:11 pm

Sorry, I'm new and a little lost, my imacros version is iMacros for Chrome V8.4.4, my Chrome version is 62.0.3202.94 (Build oficial) (64 bits), and my OS is Windows 8.1

Should i ask this in a different subforum? in that case which of them? Sorry again english is not my native language so sometimes i have trouble understanding.

Here is a capture of the web page that maybe can help to understand my problem.

http://imgur.com/DuP621R
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Filter a table

Post by chivracq » Thu Nov 30, 2017 3:45 pm

gonzalo.moraga wrote:Sorry, I'm new and a little lost,

Code: Select all

my imacros version is iMacros for Chrome V8.4.4, 
my Chrome version is 62.0.3202.94 (Build oficial) (64 bits), 
and my OS is Windows 8.1
Should i ask this in a different subforum? in that case which of them? Sorry again english is not my native language so sometimes i have trouble understanding.

Here is a capture of the web page that maybe can help to understand my problem.

http://imgur.com/DuP621R
OK for your FCI, perfect...

About the Sub-Forum, the "correct" Sub-Forum would at forehand have been the 'General' one, but your Pb (Problem) happens to be related to your FCI and to iMacros for CR only, so you've actually selected the right Sub-Forum by Luck...

I'm surprised actually you don't get any RuntimeError when running/looping your Script telling you that you need to specify '!DATASOURCE_COLUMNS' which indeed is not needed on FF/IE/iMB but required on CR, like mentioned in the Wiki...:
!DATASOURCE COLUMNS
Specifies the number of columns in the input datasource.
Note: This is only required in iMacros for Chrome, all other versions auto-detect the number of columns.
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
gonzalo.moraga
Posts: 7
Joined: Thu Nov 30, 2017 1:55 pm

Re: Filter a table

Post by gonzalo.moraga » Thu Nov 30, 2017 5:39 pm

chivracq wrote:
gonzalo.moraga wrote:Sorry, I'm new and a little lost,

Code: Select all

my imacros version is iMacros for Chrome V8.4.4, 
my Chrome version is 62.0.3202.94 (Build oficial) (64 bits), 
and my OS is Windows 8.1
Should i ask this in a different subforum? in that case which of them? Sorry again english is not my native language so sometimes i have trouble understanding.

Here is a capture of the web page that maybe can help to understand my problem.

http://imgur.com/DuP621R
OK for your FCI, perfect...

About the Sub-Forum, the "correct" Sub-Forum would at forehand have been the 'General' one, but your Pb (Problem) happens to be related to your FCI and to iMacros for CR only, so you've actually selected the right Sub-Forum by Luck...

I'm surprised actually you don't get any RuntimeError when running/looping your Script telling you that you need to specify '!DATASOURCE_COLUMNS' which indeed is not needed on FF/IE/iMB but required on CR, like mentioned in the Wiki...:
!DATASOURCE COLUMNS
Specifies the number of columns in the input datasource.
Note: This is only required in iMacros for Chrome, all other versions auto-detect the number of columns.
Thank you for your answer, i added the line to specify columns anyway but nothing changes, im desperate :?
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Filter a table

Post by chivracq » Thu Nov 30, 2017 6:11 pm

gonzalo.moraga wrote:Thank you for your answer, i added the line to specify columns anyway but nothing changes, im desperate :?
Yeah, well, post your new Script then, I won't go digging before I can see it, you can have made some Mistake or Typo in that Statement or placed it at the wrong place, etc...

Does the 'Loop' Demo btw work fine...?
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
gonzalo.moraga
Posts: 7
Joined: Thu Nov 30, 2017 1:55 pm

Re: Filter a table

Post by gonzalo.moraga » Thu Nov 30, 2017 6:31 pm

chivracq wrote:
gonzalo.moraga wrote:Thank you for your answer, i added the line to specify columns anyway but nothing changes, im desperate :?
Yeah, well, post your new Script then, I won't go digging before I can see it, you can have made some Mistake or Typo in that Statement or placed it at the wrong place, etc...

Does the 'Loop' Demo btw work fine...?
Yes, the loop demo works just fine, in fact i looked at it to know how to make my macro.

Here's my complete Script, thank you for your help.

VERSION BUILD=5301016 RECORDER=CR
'Uses a Windows script to submit several datasets to a website, e. g. for filling an online database
TAB T=1
' Specify input file (if !COL variables are used, IIM automatically assume a CSV format of the input file
'CSV = Comma Separated Values in each line of the file
SET !DATASOURCE archivoPrueba.csv
SET !DATASOURCE_COLUMNS 1
URL GOTO=http://wms.linio.cl/adm/list-awaiting-shipment.php
SET !LOOP 1
'Increase the current position in the file with each loop
SET !DATASOURCE_LINE {{!LOOP}}
' Fill web form
TAG POS=3 TYPE=INPUT:TEXT ATTR=ID:pedido CONTENT={{!COL1}}
TAG POS=1 TYPE=BUTTON ATTR=TXT:R
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Filter a table

Post by chivracq » Thu Nov 30, 2017 8:54 pm

gonzalo.moraga wrote:Yes, the loop demo works just fine, in fact i looked at it to know how to make my macro.

Here's my complete Script, thank you for your help.

Code: Select all

VERSION BUILD=5301016 RECORDER=CR
'Uses a Windows script to submit several datasets to a website, e. g. for filling an online database
TAB T=1     
' Specify input file (if !COL variables are used, IIM automatically assume a CSV format of the input file
'CSV = Comma Separated Values in each line of the file
SET !DATASOURCE archivoPrueba.csv
SET !DATASOURCE_COLUMNS 1
URL GOTO=http://wms.linio.cl/adm/list-awaiting-shipment.php
SET !LOOP 1
'Increase the current position in the file with each loop 
SET !DATASOURCE_LINE {{!LOOP}}
' Fill web form   
TAG POS=3 TYPE=INPUT:TEXT ATTR=ID:pedido CONTENT={{!COL1}}
TAG POS=1 TYPE=BUTTON ATTR=TXT:R
OK..., hum, your Script looks OK to me actually... If the Content of your '.CSV' is correct, it should work like you expect...
=> You then need to debug your Script and to follow your Vars with 'PROMPT' and '!SINGLESTEP' and/or 'PAUSE'...:

Code: Select all

VERSION BUILD=5301016 RECORDER=CR
'Uses a Windows script to submit several datasets to a website, e. g. for filling an online database
TAB T=1     
' Specify input file (if !COL variables are used, IIM automatically assume a CSV format of the input file
'CSV = Comma Separated Values in each line of the file
SET !DATASOURCE archivoPrueba.csv
SET !DATASOURCE_COLUMNS 1
URL GOTO=http://wms.linio.cl/adm/list-awaiting-shipment.php
SET !LOOP 1
'Increase the current position in the file with each loop 
SET !DATASOURCE_LINE {{!LOOP}}
' Fill web form   
PROMPT COL1:<SP>_{{!COL1}}_
TAG POS=3 TYPE=INPUT:TEXT ATTR=ID:pedido CONTENT={{!COL1}}
PAUSE
TAG POS=1 TYPE=BUTTON ATTR=TXT:R
PAUSE
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
gonzalo.moraga
Posts: 7
Joined: Thu Nov 30, 2017 1:55 pm

Re: Filter a table

Post by gonzalo.moraga » Fri Dec 01, 2017 12:35 pm

I tried using the script that you posted and i got these

The input in my CSV file is fine

https://imgur.com/a/KTT80

The seach field is filled just fine, but the rows are not being filtered.

https://imgur.com/a/tBa8v

As rows are not being filtered, the script is always pressing the first 'R' button of the page.

https://imgur.com/a/UVsBS

Here is an example of how the page look when i fill the field manually

https://imgur.com/a/q0fnO

Also, if i select the field and press the 'enter' key after is filled by the script i can filter the table, but i tried my macro to do that and couldnt do it neither :(
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Filter a table

Post by chivracq » Fri Dec 01, 2017 6:16 pm

gonzalo.moraga wrote:I tried using the script that you posted and i got these

The input in my CSV file is fine

https://imgur.com/a/KTT80

The seach field is filled just fine, but the rows are not being filtered.

https://imgur.com/a/tBa8v

As rows are not being filtered, the script is always pressing the first 'R' button of the page.

https://imgur.com/a/UVsBS

Here is an example of how the page look when i fill the field manually

https://imgur.com/a/q0fnO

Also, if i select the field and press the 'enter' key after is filled by the script i can filter the table, but i tried my macro to do that and couldnt do it neither :(
OK, I understand clearly thanks to your Screenshots. I guess the Filtering takes place "on-the-fly" as you are typing the Track Nb from some background JavaScript on the Page, or indeed if you press 'Enter', but when filling in the Input Field using the 'TAG' Mode, the Page doesn't "realize" that that Field has been filled in...

You are on v8.4.4 for CR, that's good, then you need to replace the Line in your Script:

Code: Select all

TAG POS=3 TYPE=INPUT:TEXT ATTR=ID:pedido CONTENT={{!COL1}}
... with the same Action using the 'EVENT' Mode which should do the "Trick" already...
You could maybe add a mini-'WAIT' Statement (WAIT SECONDS=0.5) before the Click on the 'R' Button to allow a little bit of time for the Filtering to take place.

If that still doesn't work, you would need to add the "Actions" of selecting the Field with the Mouse (=> 'CLICK') after it has been filled in (either using your original 'TAG' Statement (which will be quicker) or with the "new" equivalent Statement in 'EVENT' Mode (which will be a bit slower as all Chars in the Track_Nb are typed one by one)) and pressing the 'Enter' Key on your Keyboard (=> 'KEYPRESS'). That should trigger and force the Filtering then... And see if the 'WAIT' Statement is still needed or not...
(The 'CLICK' Statement will have already been recorded if you use the 'EVENT' Mode to fill in the Input Field, it's not necessary to add a second one, that whole 'CLICK' Statement is actually not needed at all and can be commented out, but iMacros will automatically record it when you need to select the Field in order to be able to press the 'Enter' Key. (But it doesn't harm, you can leave it...))

Some Mechanism you could add as well to increase a bit the "Reliability" of your Script would be to use "Relative Positioning" (=> TAG POS=R1) for the Click on the 'R' Button, by first clicking on the Field for the 'Track_Nb' in the Row as Anchor, using the 'TAG' Mode. (And you then replace the 'TXT' Attribute that will be recorded with "TXT:{{!COL1}}".)

(The "R" in "TAG POS=R1" comes from "Relative", it has nothing to do with your "R" Button, it is pure Coincidence... :oops: )

The Relative Positioning would actually already "do the Job" of selecting the correct corresponding 'R' Button if the Row was already displayed among the first 50 Results on the first Page..., even without any Filtering... 8)

>>>

Some extra Check for some extra Reliability would be to add a Check on the "Monstrando items del 1 a la 1 de un total de 1" Result Field to then trigger a Conditional 'PROMPT' or Conditional 'PAUSE' to alert the User that stg went "wrong" and that there are (still) more than 1 Result but the Relative Positioning on the 'R' Button would probably still pick the right 'R' Button or would abort the Script if the Anchor is not found... (if you don't use '!ERRORIGNORE'...)

OK, good luck and post your Final Script...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
gonzalo.moraga
Posts: 7
Joined: Thu Nov 30, 2017 1:55 pm

Re: Filter a table

Post by gonzalo.moraga » Mon Dec 04, 2017 9:26 pm

Thanks for your answer chivracq, but i couldnt make it work with none of the alternatives :( . Every time i did a keypress or click event i got a message that imacros was debugging my browser. So i had to choose a most inneficient solution, i used javascript and firefox so i made a nested loop that search for all of the tracking numbers in my data source in every page of the table, and i used the relative positioning to press the 'R' button. I know that is far of being the best solution, but at least is working.

var numGuias = prompt("Cuantas guias vas a expedir?");
var numPags = prompt("Cuantas paginas tiene la tabla?");

for(var i = 1; i <= numPags; i++){
var macro = "CODE:" + "\n";
//macro +="URL GOTO=http://wms.linio.cl/adm/list-awaiting-shipment.php" + "\n";
macro += "TAG POS=1 TYPE=A ATTR=TXT:" + i;
iimPlay(macro);
for(var j = 1; j <= numGuias; j++){
var macro2 = "CODE:" + "\n";
macro2 += "SET !DATASOURCE archivoPrueba.csv" + "\n";
macro2 += "SET !ERRORIGNORE YES" + "\n";
macro2 += "SET !DATASOURCE_COLUMNS 1" + "\n";
macro2 += "SET !DATASOURCE_LINE " + j + "\n";
macro2 += "SET !TIMEOUT_TAG 0" + "\n";
macro2 += "TAG POS=1 TYPE=SPAN ATTR=TXT:{{!COL1}}" + "\n";
macro2 += "TAG POS=R1 TYPE=BUTTON ATTR=TXT:R" + "\n";
//macro2 += "WAIT SECONDS = 0.3";
iimPlay(macro2);
}
}

Here is my js code, basically i ask the user how many pages the table has and how many numbers he wants to find and then in each page the script looks for every number and if its there then press the button.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Filter a table

Post by chivracq » Tue Dec 05, 2017 12:07 am

gonzalo.moraga wrote:Thanks for your answer chivracq, but i couldnt make it work with none of the alternatives :( . Every time i did a keypress or click event i got a message that imacros was debugging my browser. So i had to choose a most inneficient solution, i used javascript and firefox so i made a nested loop that search for all of the tracking numbers in my data source in every page of the table, and i used the relative positioning to press the 'R' button. I know that is far of being the best solution, but at least is working.

Code: Select all

var numGuias = prompt("Cuantas guias vas a expedir?");
var numPags = prompt("Cuantas paginas tiene la tabla?");

for(var i = 1; i <= numPags; i++){
	var macro = "CODE:" + "\n";
	//macro +="URL GOTO=http://wms.linio.cl/adm/list-awaiting-shipment.php" + "\n";
	macro += "TAG POS=1 TYPE=A ATTR=TXT:" + i;
	iimPlay(macro);
	for(var j = 1; j <= numGuias; j++){
		var macro2 = "CODE:" + "\n";
		macro2 += "SET !DATASOURCE archivoPrueba.csv"  + "\n";
		macro2 += "SET !ERRORIGNORE YES" + "\n";
		macro2 += "SET !DATASOURCE_COLUMNS 1"  + "\n";
		macro2 += "SET !DATASOURCE_LINE " + j + "\n";
		macro2 += "SET !TIMEOUT_TAG 0" + "\n";
		macro2 += "TAG POS=1 TYPE=SPAN ATTR=TXT:{{!COL1}}" + "\n";
		macro2 += "TAG POS=R1 TYPE=BUTTON ATTR=TXT:R" + "\n";
		//macro2 += "WAIT SECONDS = 0.3";
		iimPlay(macro2);
	}
}
Here is my js code, basically i ask the user how many pages the table has and how many numbers he wants to find and then in each page the script looks for every number and if its there then press the button.
Euh yep, I just did some Testing on CR for some other Thread, and I saw indeed this "... debugging..." Warning [Cancel/Close] and I just found out that the 'EVENT' Mode seems to be pretty Buggy on CR indeed...
(I don't like CR, so I never used it, I only (re)installed it very recently on a "new" Laptop that I've already been using for nearly 2 years, but some Thread came a few weeks ago, that was specific to CR, so I finally reinstalled that ugly Browser, and iMacros for CR (v8.4.4) with it of course... Beurk...! :oops: )

So OK, you switched to FF, OK..., good-good actually... There was no real Need to use a '.js' Script in your Case, I would think, but your Script looks neat, nice Nested Loop indeed, even if it could easily be done in pure '.iim'..., but hum, watch out with '!TIMEOUT_TAG', Deprecated Command since about 8 years I think, I'm not even sure it still works on v9.0.3 for FF..., and you should mention on which FCI your Script works... :idea:

But OK, if you now have a working Script, I guess you're already "happy enough"... :wink:

Hum, and mini-Advice, you should use more English in your Script, Var-Names in some exotic Language don't make it easy if you need to ask for Help on the Forum... :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
gonzalo.moraga
Posts: 7
Joined: Thu Nov 30, 2017 1:55 pm

Re: Filter a table

Post by gonzalo.moraga » Tue Dec 05, 2017 2:02 pm

My script works in Firefox 47.0.1, Windows 8.1 and iMacros for Firefox 8.9.7

Thank you again for your help chivracq, I will follow your recommendation about var names if I have another issue in the future.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Filter a table

Post by chivracq » Tue Dec 05, 2017 4:05 pm

gonzalo.moraga wrote:My script works in

Code: Select all

Firefox 47.0.1, Windows 8.1 and iMacros for Firefox 8.9.7
Thank you again for your help chivracq, I will follow your recommendation about var names if I have another issue in the future.
OK..., yep..., '!TIMEOUT_TAG' still backward supported in v8.9.7 indeed...,but you should still replace it with '!TIMEOUT_STEP'...
(And v8.9.7 still works until (at least) FF v55.0.3 btw, FCI I use myself...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply