如何将脚本属性值存储为整数。
if(PropertiesService.getScriptProperties().getProperty('setnumber'))
{
var setnumber = Number(PropertiesService.getScriptProperties().getProperty('setnumber')) + Number(1);
}
else
{
var setnumber = Number(PropertiesService.getScriptProperties().setProperty('setnumber', 1)); // this value gets stored as 1.0 or returns undefined
}
var numofrow = 500;
var maxvalue = numofrow * setnumber; //returns undefined
答案 0 :(得分:2)
setProperty
不返回值,而是为属性设置值。请参阅以下代码。
var setnumber = 1;
if(PropertiesService.getScriptProperties().getProperty('setnumber'))
{
setnumber = parseInt(PropertiesService.getScriptProperties().getProperty('setnumber')) + 1;
PropertiesService.getScriptProperties().setProperty('setnumber', setnumber);
}
else
{
PropertiesService.getScriptProperties().setProperty('setnumber', setnumber); // you can't assign this to a variable
}
var numofrow = 500;
var maxvalue = numofrow * setnumber; //returns undefined
Logger.log(maxvalue)