I'm helping an educational project. The following is the request:
the words-sentences in 1 row from a google spreadsheets list should be sent automatically to the discord text channal every day. The next day, a line below. When the whole list is finished, it should go back to the beginning and send it again. and write it on a new line after each column.
2nd request: same but this time 2 rows should be sent every day. Number of columns Generally the same 2 or 3.
this is the code i found works, but that's not what i wanted. this code is for:"a range of cells".
How do I get it to send the next line every day? I will set the code to run once a day with Trigger from the menu. But how will it know which line it sent yesterday, etc.?
Unfortunately, I couldn't do exactly what I wanted. I will be glad if you help
(I'm an IT person, but I don't have any coding knowledge. I understand the code when I see it, but I can't write it.)
Code:
function propertyServExample() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Loot");
var propertyServ = PropertiesService.getScriptProperties();
var properties = propertyServ.getProperties(); //get script properties
var row = 1; // set initial row
if(Object.getOwnPropertyNames(properties).length != 0){ //this will check if the properties object is not empty
row = parseInt(properties["row"]) 3;
}
var range = sheet.getRange(row, 1, 3, 2);
var values = range.getValues();
var str = '';
values.forEach(val => {
str = str val.join('') '\n';
})
Logger.log(str);
propertyServ.setProperty("row", row); //save the current row of processed line
}
Each run will get the next row.
Run 1:
Run 2:
Run 3: