Hello all,
I'm currently working on a project where I need to send data to the app script in order to apply a filter to the google sheet with sent data.
The issue is that the connection is here but the filter didn't apply.
I applied the filter function manually through the app script and it works.
I think its something wrong with the doGet and doPost or the tagData
function doGet(e) {
var ss = SpreadsheetApp.openByUrl("SheetUrl")
var sheet = ss.getSheetByName("testo");
var params = JSON.stringify(tagData(e,sheet));
return HtmlService.createHtmlOutput(params);
}
function doPost(e) {
var ss = SpreadsheetApp.openByUrl("SheetUrl")
var sheet = ss.getSheetByName("testo");
ContentService.createTextOutput(fJSON.stringify(e))
}
function tagData(e,sheet) {
var Location = e.parameter.Location;
sheet.append([Location]);
return { Location: Location }
}
function filterOnText() {
var ss = SpreadsheetApp.getActive();
var range = ss.getDataRange();
var filter = range.getFilter() || range.createFilter()
var text = SpreadsheetApp.newFilterCriteria().whenTextContains(Location);
filter.setColumnFilterCriteria(1, text);
In your App Inventor app you are using POST. This means that the google apps script will run doPost(e) when it receives parameters.
Your current doPost:
function doPost(e) {
var ss = SpreadsheetApp.openByUrl("SheetUrl")
var sheet = ss.getSheetByName("testo");
ContentService.createTextOutput(fJSON.stringify(e))
}
will only return what you have sent it. It is not activating either the tagData or filterOnText functions.
Without seeing the spreadsheet, it is difficult to advise further.
Also, if you just need a subset of data back to the app, it might be easier to use a query....