Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/408.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 谷歌应用程序脚本doGet_Javascript_Google Apps Script - Fatal编程技术网

Javascript 谷歌应用程序脚本doGet

Javascript 谷歌应用程序脚本doGet,javascript,google-apps-script,Javascript,Google Apps Script,我的代码有问题。谷歌不赞成使用一些有效的软件。现在,当我制作一份新的工作表并尝试使用旧的代码时,我会遇到错误,并且找不到在google上修改文档的方法 function doGet(e) { //This is not working? if (typeof e.parameter.id == 'undefined'){ return no_id(e) // The URL doesn't have an ?id=345 on the end!

我的代码有问题。谷歌不赞成使用一些有效的软件。现在,当我制作一份新的工作表并尝试使用旧的代码时,我会遇到错误,并且找不到在google上修改文档的方法

function doGet(e) {

    //This is not working?

    if (typeof e.parameter.id  == 'undefined'){     
        return no_id(e) // The URL doesn't have an ?id=345 on the end!
    }

    var id = parseInt( e.parameter.id ) // This is the id of the row in the spreadsheet.

    //Script properties is changed and I think it is now: PropertyService.getScriptProperties() // Get the data from the spreadsheet and get the row that matches the id

    var this_spreadsheet_id = ScriptProperties.getProperty('this_spreadsheet_id')
    var ss = SpreadsheetApp.openById(this_spreadsheet_id)
    var sheet = ss.getSheetByName("Sheet1")
    var range = sheet.getDataRange()
    var last_row = range.getLastRow()
    var last_column = range.getLastColumn()

    for(i = 2; i <= last_row ; i++){

        var this_row = sheet.getRange(i,1 , 1, last_column)
        var values = this_row.getValues()[0]
        var row_id = parseInt( values[0] )

        //row id == id is not working either

        if ( row_id == id){        
            var title = values[5]
            var details = values[8]
            var status_txt = values[7]

            Logger.log( "STATUS: " + status )

            var image_url = values[4]
        }
    }
}
函数doGet(e){
//这不管用吗?
如果(typeof e.parameter.id=='undefined'){
return no_id(e)//URL末尾没有?id=345!
}
var id=parseInt(e.parameter.id)//这是电子表格中行的id。
//脚本属性已更改,我认为现在是:PropertyService.getScriptProperties()//从电子表格中获取数据并获取与id匹配的行
var this\u spreadsheet\u id=ScriptProperties.getProperty('this\u spreadsheet\u id')
var ss=SpreadsheetApp.openById(此电子表格id)
var sheet=ss.getSheetByName(“Sheet1”)
var range=sheet.getDataRange()
var last_row=range.getLastRow()
var last_column=range.getLastColumn()
对于(i=2;i),未定义引用错误:“id”。(第23行,文件“代码”)

在定义id之前,if语句中有一个返回。因此,如果未定义返回,则会触发if语句。请将变量定义移到顶部

var id = parseInt( e.parameter.id ) // This is the id of the row in the spreadsheet.

//Script properties is changed and I think it is now: PropertyService.getScriptProperties() // Get the data from the spreadsheet and get the row that matches the id

var this_spreadsheet_id = ScriptProperties.getProperty('this_spreadsheet_id')
var ss = SpreadsheetApp.openById(this_spreadsheet_id)
var sheet = ss.getSheetByName("Sheet1")
var range = sheet.getDataRange()
var last_row = range.getLastRow()
var last_column = range.getLastColumn()

if (typeof e.parameter.id  == 'undefined'){     
    return no_id(e) // The URL doesn't have an ?id=345 on the end!
}
ReferenceError:“id”未定义。(第23行,文件“代码”)

在定义id之前,if语句中有一个返回。因此,如果未定义返回,则会触发if语句。请将变量定义移到顶部

var id = parseInt( e.parameter.id ) // This is the id of the row in the spreadsheet.

//Script properties is changed and I think it is now: PropertyService.getScriptProperties() // Get the data from the spreadsheet and get the row that matches the id

var this_spreadsheet_id = ScriptProperties.getProperty('this_spreadsheet_id')
var ss = SpreadsheetApp.openById(this_spreadsheet_id)
var sheet = ss.getSheetByName("Sheet1")
var range = sheet.getDataRange()
var last_row = range.getLastRow()
var last_column = range.getLastColumn()

if (typeof e.parameter.id  == 'undefined'){     
    return no_id(e) // The URL doesn't have an ?id=345 on the end!
}

请使用apps脚本调试器逐行执行。在上面的代码中包含每个变量的值。Google不推荐使用的是什么?我计算出了脚本属性的脚本更改。if(row_id==id)是调试器现在出错的地方。当前调试器读取的“ReferenceError:”id“未定义。(第23行,文件“代码”)该id设置在顶部变量id中。我只是没有任何线索,感到非常沮丧。我不理解parseInt命令,坦率地说,我不太理解。我正在尝试学习,正在作为志愿者参与一个项目,但我被绊倒了。请使用应用程序脚本调试器逐行进行调试。在中包含每个变量的值上面是您的代码。Google不推荐使用的是什么?我计算出了脚本属性的脚本更改。if(row_id==id)是调试器现在出错的地方。当前调试器读取“ReferenceError:”id“未定义。(第23行,文件“code”)”id设置在最上面的var id中。我只是没有任何线索,感到非常沮丧。我不理解parseInt命令,坦率地说,我不太理解。我正在尝试学习,并且作为一名志愿者在一个项目中工作,但我被绊倒了。