问题
I know that auto-completion sometimes helps you find unreferenced methods of Google objects such as for the Sheets API v4 but how can I find the attributes.
example with spreadsheets:
function onEdit(e)
{
Logger.log(e.range.columnStart)
//returns the start column of the range I've edited
Logger.log(SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getDataRange().columnStart)
//Weird result, even if my sheet is populated with values it returns 'undefined'
}
In this example you see the attribute columnStartbut I can't find it in documentation however a lot of people seems to use it.
Another point that can be out of subject but interesting, both e.range and getDataRange returns a Range object but one seems to have a populated columnStartattribute when the other don't.
回答1:
- You want to retrieve the object of
e.rangefromonEdit(e).
If my understanding is correct, how about this answer? Unfortunately, the detail properties cannot seen at the document of Event Objects. So, for example, it confirms each properties from the event object using JSON.stringify().
Sample script:
function onEdit(e) {
Logger.log(JSON.stringify(e)) // or console.log(JSON.stringify(e))
}
Result:
{
"authMode": {},
"range": {
"columnStart": 1,
"rowStart": 1,
"rowEnd": 1,
"columnEnd": 1
},
"source": {},
"user": {
"nickname": "### name ###",
"email": "### email ###"
},
"value": "sample"
}
Note:
- If
Logger.log(JSON.stringify(e.range))is run,{"columnStart":1,"rowStart":1,"rowEnd":1,"columnEnd":1}is retrieved. In this case, "A1" is edited.
Reference:
- Event Objects
来源:https://stackoverflow.com/questions/52248268/where-can-we-find-non-documented-attributes-of-google-objects