You have no spaces between var and the variable name, e.g. varss.
They should look like this:
var ss = SpreadsheetApp.getActive();
var sh = ss.getSheets()[0];
var rg = sh.getDataRange().getValues();
var sql = e.parameter.SQL;
var qry = '=query(' + rg + ';\"' + sql + '\";1)';
I tried to modify the blocks, similar to the other 3 "set.Web(n°).Url to", therefore joining "get global Url" and "&func=Query" at the beginning, but it still doesn't work, showing still the same error:
Runtime Error
The operation Elements cannot accept the arguments: , ["<!DOCTYPE"] Note: You will not see another error reported for 5 seconds.
You could also just add another worksheet to your google sheet, and test your query on the google sheet, using the QUERY= formula (which is what the apps script is ostensibly doing)
I have to say, this second method looks a bit easier to me (maybe more low-code and straightforward).
I have downloaded the "gvizQueryDemo.aia" provided in the example, and modified a bit to try understanding the logic, and it works as expected.
Now I'm trying to apply the same logic to my app, but I am getting error message in return:
*Runtime Error*
*The operation Elements cannot accept the arguments: , ["{"version":"0.6","reqId":"0","status":"error","errors":[{"reason":"invalid_query","message":"INVALID_QUERY","detailed_message":"Invalid query: NO_COLUMN: Targa"}]}"]*
**Note:* You will not see another error reported for 5 seconds.*
If I try to indicate in the query the column name by letters instead of headers, this is the error message:
Runtime Error
*The operation Elements cannot accept the arguments: , ["{"version":"0.6","reqId":"0","status":"error","errors":[{"reason":"invalid_query","message":"INVALID_QUERY","detailed_message":"Invalid query: NO_COLUMN: NO_Lancioni"}]}"]
**Note:* You will not see another error reported for 5 seconds.
I think you have a point: I have now updated the blocks in order to enter the string to compare between single quotes (see image).
It does give me error, but another kind:
*Runtime Error*
*The operation Elements cannot accept the arguments: , [""Targa" "naceas" "AV624DF" "EA729LK""]*
**Note:* You will not see another error reported for 5 seconds*
From the elements listed in the error, the first is the header of the Column to filter, the other 3 are indeed the data filtered... I don't understand why it shows an error, but I think it gets the "filtering" function, as it extract just those data...
Hi, we are getting close, but still some trouble arising...
The filter is now working, and I manage to exclude the first item (the header), adding the block "all but first of list". Perfect!
Now the problem is the following, with the Script "ReadRecord".
Before, when in the ListView1 appeared all the records, selecting one, thanks to the Script "ReadRecord" I could see in the labels fields n° 2-3-12-13 (Web2.GotText).
Now instead, it doesn't read the selected row, but it starts from row 1 of the Database... meaning, if I pick in ListView1 the third element, the Script doesn't read its record, but always the third record of the database...
Any idea how to fix this? Thanks a lot
I'm uploading both the new blocks, and new google app script
Ok I think I figured out the logic of the mistake... but I don't know how to fix it!
Once created a filtered list, with "ListView1.SelectionIndex", I'm creating a new list with index starting at 1: so, even if in the original Database the element is n°50, if in the new list appears first, it has index n° 1. Therefore, the scripts "ReadRecord" and "Update", are working on index n° 1 of the Database... which is wrong.
I need to understand if it's possible to indicate to those scripts the right index of the selected element...
Like you have removed the first row (col header) you need to add 1 (+1) to the SelectionIndex to meet with the row you want.
The first element in the ListView has index 1, but it is the row 2 in the sheet.
EDIT: Ok, Sorry, now I understand the problem...you have a filtered list where the order is not the row number.
Then you need to use a unique value to be able to identify the row.
Other option could be to get all the rows in a list, displaying in the ListView only the filtered data, and when an element is selected, you can find its position in the whole list to do the new query.