This is a question about the trigger when inserted from CF7 into Google spreadsheet.

Asked 2 years ago, Updated 2 years ago, 37 views


when inserting data from CF7 Google Sheet Connector into Google spreadsheet It will be added to the bottom of sheet 1, but I would like to put it in reverse order to sheet 3.
I wrote the following JavaScript.

So, regarding the trigger,
Select event source:
from spreadsheet Select Event Type: Edit
So, even if you insert it into sheet 1 from CF7 Google Sheet Connector, the GAS is
Does not work,
Select event source:
from spreadsheet Select event type:when changing
If so, the GAS will work just by changing the row width and column width of sheet 3.

in JavaScript if(sheet_add.getName()=="sheet1"){
I only want to move the GAS when seat 1 is activated as , but
of seat 3 Why does the GAS work in line width and column width?

//FormApp.getActiveForm()

function reverse() {

    var spreadsheet=SpreadsheetApp.getActiveSpreadsheet(); // Container Bound Script
    varsheet_add=spreadsheet.getActiveSheet();

    if(sheet_add.getName()=="sheet1"){

        // retrieve a spreadsheet
        varsheet=spreadsheet.getSheets()[0]; // Get by specifying sheet 1
        var lastRow=sheet.getRange(sheet.getMaxRows(), 1).getNextDataCell(SpreadsheetApp.Direction.UP).getRow();

        range=sheet.getRange(lastRow, 1, 1, 13);
        varcurrentRangeValues=range.getValues();

        varsheet3=spreadsheet.getSheets()[2]; // Get by specifying sheet3

        var numRows = currentRangeValues.length;
        var numColumns=currentRangeValues[0].length;

        sheet3.insertRows(2,1);
        sheet3.getRange(2,1,numRows,numColumns).setValues(currentRangeValues);

    }

}

google-apps-script

2022-09-29 21:39

1 Answers

Self-solving? I did.
In the end, copying data from the same spreadsheet to another sheet triggers a trigger, so we copy the data to a completely different spreadsheet and make a stopgap move because it does not trigger the original spreadsheet on the destination spreadsheet.


2022-09-29 21:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.