Google电子邮件:触发工作表脚本的按钮/链接 [英] Google Email: Button/Link which trigger a script for sheet
问题描述
我正在寻找一种使用Google App Script发送电子邮件的方法(我知道该怎么做),该方法包括批准按钮/链接.当用户单击电子邮件中的链接/按钮以批准请求时,我想触发一个脚本(这是我可能不知道的电子邮件部分),该脚本返回到Google表格并更改单元格中的值.
I am looking for a way to send an email with Google App Script (I know how to do that) which includes an approval button/link. When the user clicks the link/button in the email to approve the request, I want to trigger a script (this is the part I do not know if possible from email) which goes back to the Google Sheet and changes a value in a cell.
示例: 用户A使用google表单提交请求,并且在SheetA中追加了新行.使用某些公式,我自动将ID = X关联到该请求/行.然后,脚本将向用户B发送一封电子邮件,以请求批准用户A的请求.用户B单击电子邮件中的链接,脚本将在SheetA中找到记录X,并更新该行中的值.
Example: User A submits a request using google form, and a new row is appended in SheetA. With some formulas, I automatically associate an ID = X to that request/row. A script will then send an email to user B to ask to approve the request of user A. User B will click a link in the email and the script will find the record X in SheetA and update a value in that row.
推荐答案
您可以使用类似代码的
function doGet(e) {
params = e.parameter;
var range=e.parameter.range;
var value=e.parameter.value;
SpreadsheetApp.openById('SHEETID').getRange(range).setValue(value);
return HtmlService.createHtmlOutput(`<b>${range}</b> set to <b>${value}</b>`);
}
使用像我一样执行",所有人,甚至是匿名"选项来发布它, 然后使用链接执行它
publish it with "execute as me", "everyone, even anonymous" options, and then exec it using a link
https://script.google.com /macros/s/SCRIPTID/exec?range = B1& value = 100
这篇关于Google电子邮件:触发工作表脚本的按钮/链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!