来自HtmlService的基本响应(无异步对话框)

时间:2019-02-19 10:32:28

标签: google-apps-script

我有一组代码,我需要打开多个yes / no对话框以及2个HtmlService对话框。顺序如下

HtmlService(具有返回表单数据的功能的表单)->对话框(是_否),以确认表单上的价格正确。 ->对话框(YES_NO)确认选定的日期范围-> HtmlService验证电子邮件。

我的问题来自最后一个HtmlService对话框。我已经有需要传递给处理函数的数据,但据我所知,将变量放入HtmlService的唯一方法是将数据作为由HtmlService运行的函数返回。因此,从上述第一个HtmlService的处理顺序开始,将表单数据传递给名为“ confirmer()”的函数,在该函数中,我运行其他两个对话框。

我的问题是,当HtmlService在“ confirmer()”函数内部运行时,如何将数据从“ confirmer()”获取到新的HtmlService中。或者如何从HtmlService获得简单的同步响应(如标准ui.alert()响应)?

function create_dialog() { //creates the first HtmlService
    var html = HtmlService.createTemplateFromFile('appointments dialog').evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME).setWidth(300).setHeight(350);
    SpreadsheetApp.getUi().showModalDialog(html, 'Create Appointment');
}

function confirmer(date, rec, end, location, price, semail, scalander, name, description, status, user, clientmail){ //this is the response from google.script.run.confimer(*vars)
    var response = ui.alert('Price Confirm', 'Is the price £'+String(price)+'correct? ', ui.ButtonSet.YES_NO);
    if (response == ui.Button.YES){
        var response = ui.alert('Date Confirm', 'Are the following Dates correct?\n'+strdates, ui.ButtonSet.YES_NO);
        if(response == ui.Button.YES){
            //this is where i need to pass the variables (date, rec, end, location, price, semail, scalander, name, description, status, user, clientmail) to the new HtmlService
            var emailpreview = emesage("Your", "is", name, date, location, alias, get_email(user), price); //this just generates pure HTML.
            var html = HtmlService.createTemplate(emailpreview).evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME).setWidth(300).setHeight(350);;
            SpreadsheetApp.getUi().showModalDialog(html, 'Email');
            //if(dialog == pressed yes){update_sheet(*vars) //i need to run this (pseudo code)
}

0 个答案:

没有答案