I wish to run the next script, with a script.
When function "ConfigureTest1" has run, it should simply start "ConfigureTest2" and so on...
This is what I have, so far:**
function ConfigureTest1() {
const ss = SpreadsheetApp.getActiveSpreadsheet()
const sh = ss.getSheetByName('TEST')
sh
.getRange('A2:A')
.createTextFinder('T')
.replaceAllWith('TEST')
ScriptApp.newTrigger('ConfigureTest2') // RUN function ConfigureTest2
.create();
}
function ConfigureTest2() {
let ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("AUTO")
let data = ss.getRange(1, 1, ss.getLastRow(), 1).getValues()
let initialData = data.map(function(r) {
return r[0];
})
let conde = ["TEST"]
let writea = ["TEST"]
let rowNumber = 2
for (i = 0; i <= ss.getLastRow() - 2; i ) {
for (j = 0; j <= conde.length - 1; j ) {
if (initialData[i].includes(conde[j])) {
ss.getRange("B" rowNumber).setValue(writea[j])
break
}
ss.getRange("B" rowNumber).setValue("TEST")
}
rowNumber
}
}
CodePudding user response:
You can just add ConfigureTest2()
after creating the trigger like this:
function ConfigureTest1() {
//what you already have
ConfigureTest2()
}
I'm not sure what's your final purpose with the script, but as some additional advice, the TriggerBuilder documentation explains that you first need to specify what kind of trigger this is along with the ID of the document that you want to attach it to, and then specify the type of trigger, so your trigger creation should look more like this:
ScriptApp.newTrigger('ConfigureTest2')
.forSpreadsheet("<Your-spreadsheet-ID>")
.onOpen() //or edit, etc.
.create();
And also note that the includes method applies to an entire array, but you're trying to call it on just one element of it, so instead of this:
if (initialData[i].includes(conde[j])) {
You need to change it to this:
if (initialData.includes(conde[j])) {
This does copy some "TEST" data to a different column when you run ConfigureTest1
, but again, I'm not sure what your goal is. At least this should solve the syntax errors so you can focus on the logic of the script.