all! Newbie to Google Scripts, but I'm a fair-to-middlin' user of Tasker. Back in August I added a script to my spreadsheet to automatically sort two columns onEdit, based on a value in a cell. The spreadsheet is populated and the specific cell is changed from a Tasker plugin. In August, it worked fine! Everytime I added a row using Tasker, it populated the spreadsheet and immediatly sorted the spreadsheet without me needing to open the file.
Now it doesn't. I hadn't changed anything at the time, but I know any number of things could have changed - including Android, Tasker, Spreadsheet Update Plugin, or Google Scripts itself. Tasker would correctly populate the sheet and/or change the cell value, but the spreadsheet wouldn't sort. I'd open the sheet, the data would be added at the bottom of the sheet, but it wasn't sorted. I'd have to change the value of any cell to get it to sort while I had it open.
So, I searched the GS Developer pages, Stack Overflow, QnA, Google Groups page, even the Tasker Reddit and Google Group. In that process, I broke my sort all together and just now returned it to it's previous state: successfully populated from Tasker, but not sorting unless I open it.
I'm excited to get this working again. I'm very pleased with my automated system and want to share it with the different communities involved (Tasker, AutoApps, KWGT, and Google Drive). I can say to my phone that I spent money, it updates my expenses spreadsheet, which updates my phone widget to show me how much I've spent of my monthly budget. I also have a CookBook Tasker Project that, after selecting a recipe, will update my shopping list spreadsheet with the ingredients and puts it on my phone widget that would sort by the store I'm going to and will let me check off the items from the list. As it is, this shopping widget is useless now.
Has something changed? Is it no longer possible to trigger an onEdit when the sheet is changed from a third party? Here's the code I was using ... super simple because I do not know javascript, but it worked once and I'd love it to work again!
Thank you for your time!
function onEdit(e){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var storepicked = sheet.getRange("H1").getValue();
{
sheet.sort(7,false);
}
if (storepicked == 1) {
sheet.sort(4);
}else if (storepicked == 2) {
sheet.sort(5);
}else if (storepicked == 3) {
sheet.sort(6);
}
{
sheet.sort(7,false);
}
}