我正在寻找一种预先填写的方法。一个谷歌表格,其中包含谷歌应用程序的特定数据。您可能知道,当用户登录表单时,它会检索它的用户名,那么如何将其他已知字段(电子邮件,电话,部门)放入谷歌表单?
答案 0 :(得分:0)
如果你想建立自己的表格
的 Code.gs
function doGet() {
return HtmlService.createTemplateFromFile('index').evaluate()
.setTitle('MyTitle')
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
}
function getEmail(){
return Session.getActiveUser().getEmail();
}
function test(){
Logger.log(Session.getActiveUser().getEmail());
}
index.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<form>
email: <br>
<input name="firstname" id="email">
<br>
name:<br>
<input type="text" name="lastname"><br>
<button> send </button>
</form>
<script>
google.script.run.withSuccessHandler(onSuccess).getEmail();
function onSuccess(email){
var elem = document.getElementById("email");
elem.value = email;
}
</script>
</body>
</html>