i used many codes to sort the data coming from mit app inventor but still sorting when i enter values manually not sorting the values after getting from mit app inventor
here are the codes i used if you can help me to adjust any as i wanna sort the data due to multiple columns
i tried many codes honesty even used the AI equations, but the data coming from the mit app inventor app to the google sheet isnt being sorted auto with the script equation, if i added data manually in the sheet is being sorted but any new additions from the app to the sheet isnt being sorted, so is there a way to fix that?
i tried auto sort function, on edit and on change and i asked ai for the help but still no auto changes when i send the data from mit app inventor to google sheet
let me show you
am collecting ordersa from customers on the app and then the data is being sent on googlesheet
so i have multiple columns on google sheet needs to be auto sorted, date column, time column so on
so when the new customer send a new order the data should be auto sorted on google sheet so when i back orders to drivers, the drivers can eliminate the similar orders to collect the similar order by numbers to make thier orders completed
it i couldn't sort the google sheet by the script code
so can you help me to make an equation like this by blocks for the list view elements
if the date is similar, time is similar, location, arrive place, travel type are similar then sum the people num chosen?
I have built up a simple apps script web app to demonstrate sorting of a sheet, then to return values.
SCRIPT
function doGet(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var lr = sheet.getLastRow() -1;
var range = sheet.getRange(2,1,lr,5);
var fn = e.parameter.FN;
if (fn == "i") {
range.sort(1);
}
else if (fn =="d") {
range.sort(2);
}
else if (fn =="n") {
range.sort(3);
}
SpreadsheetApp.flush();
var vals = range.getDisplayValues();
return ContentService.createTextOutput(JSON.stringify(vals));
}
note the use of SpreadsheetApp.flush(), which ensures all operations on the spreadsheet are completed before running the next command in the script.
SHEET
You supply the script with a single parameter value for FN, either i to sort by the id column, d to sort by the date column, or n to sort by the name column. The url you would send should look like this:
The script returns a stringifed json of values from the spreadsheet, which you need to convert back into an AI2 list using the JsonTextDecode block from the web component
You can, of course, modify this script to return a sort of your choosing...
thanks so much for your effort but lets show me more, do you mean the data will be sorted on the sheet first before i get it back to the list view or the verse
let me show you in the video of my sheet when adding a new order
if you noticed that the new order didnt be sorted after adding the equation
the translated columns that i wanna sort sequence and after that wanna get the sum for the num people for the similar orders after sorting,
i hope to understand me so i wanna know will it be sorted by that or should get the data to the listview first to sort !
are you aware that for your app you do not need the Google Spreadsheet itself sorted, the Spreadsheet is only a database and for the database it does not really matter if the data is sorted of not...
what you need is to get the data sorted from the spreadsheet into your app
to sort a Google Spreadsheet actually is out of scope for this community
i cant arrange data from it any written text then the already written in the pic isnt working
let me show you my request and tell me what can i do with your creativity
there are about 10 columns from the 12 columns in the sheet needs to be arranged with the similar cells
similar date, time, so on as you see in the screenshot
and after arranging the data i need to get the sum of num people column for the similar arranged
for example
1 order 1 jan 8am from egypt to usa
2 order 20dec 11am from egypt to mexico
3 order 15feb 8pm from mexico to egypt
so it needs to be arranged like that
1 order 1 jan 8am from egypt to usa
3 order 15feb 8pm from mexico to egypt
2 order 20dec 11am from egypt to mexico
i dont care about where can i arrange them inside the app or outside, the only important thing is to arrange multiple columns with the similar so if it can be by block and then show them arranged in the listview directly it will be great