I have created a function which trigger every after 30 mins, and I want to pass some parameter. I have one library which returns carHistory, and my spreadsheet from where I call library function.
Library1.gs
function carHistory(number,maker)
{
// code logic
}
function startEvery30mins_CarHistory(number,maker)
{
//This function works
carHistory(number,maker);
// how to trigger this with parameter.
ScriptApp.newTrigger("carHistory")
.timeBased()
.everyMinutes(30)
.create();
}
In my SpreadSheet
Code.gs :
function startOnce(){
Library1.carHistory("US-xxx","Honda");
}
function startEvery30mins(){
Library1.startEvery30mins_CarHistory("US-xxx","Honda");
}
EDITED:
Code.gs: I tried using PropertiesService, but still not working
function startOnce(){
var uProps = PropertiesService.getUserProperties();
uProps.setProperty('Maker', 'Honda');
uProps.setProperty('Number', 'US-xxx');
Library1.carHistory();
}
Library :
function carHistory()
{
// Fetch Parametr
var getProps=PropertiesService.getUserProperties();
var c_Maker= getProps.getProperty('Maker');
var c_Number=getProps.getProperty('Number');
// code logic
}
function startEvery30mins_CarHistory()
{
ScriptApp.newTrigger("carHistory")
.timeBased()
.everyMinutes(30)
.create();
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…