我试图让这两个新触发器成为我现有功能的一部分。我曾经有一个工作,当我添加第二个时,两个触发器不会同时创建。请帮助。
// Trigger every 15 Minutes
ScriptApp.newTrigger('copyPriceData')
.timeBased()
.everyMinutes(2)
.create();
//Delete Trigger after Market Closes
ScriptApp.newTrigger("delete_Triggers")
.timeBased()
.after(6 * 60 * 1000)
.create();
现有代码是:
function CopyLive1() {
var date = new Date();
var day = date.getDay();
var hrs = date.getHours();
var min = date.getMinutes();
if ((hrs >= 15) && (hrs <= 15) && (min >= 46) && (min <= 46)) {
var sheet = SpreadsheetApp.getActiveSheet();
// Get more recent closing prices
var closePriceRange = sheet.getRange("F4");
var prevClosePriceRange = sheet.getRange("F5");
var closePrice = closePriceRange.getValue();
var prevClosePrice = prevClosePriceRange.getValue();
// Check if price data has updated. If so create new row and copy price data.
if (closePrice != prevClosePrice)
{sheet.insertRowsAfter(4, 1);
var rangeToCopy = sheet.getRange("B4:G4");
rangeToCopy.copyTo(sheet.getRange("B5:G5"), {contentsOnly:true});
}
sheet.deleteRow(1825);
}
}