如何将脚本属性值存储为整数。
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
最佳答案
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)
关于javascript - Google Apps脚本将脚本属性值存储为整数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45491490/