reload page google apps script

2019-08-30 11:24发布

问题:

How do i reload a page in google sites using google apps script? I have a function that creates a form and another function doPost to collect the data submited in the form and writes it in a spreadsheet. The spreadsheet is embbeded in the same page and i want the page to reload to update the view in the spreadsheet.

I tried to find some function or service in Site Services and Ui Services.

here are the code

function doGet(e) {
var appRegistro = UiApp.createApplication().setTitle('Registre seu Atendimento!').setHeight(500);
var form = appRegistro.createFormPanel();
var flow = appRegistro.createFlowPanel();
var date=new Date();

//Construção do Menu
flow.add(appRegistro.createLabel("Data"));
  flow.add(appRegistro.createTextBox().setName("Data").setValue(date).setReadOnly(true).setText(Utilities.formatDate(date, "GMT -02:00", "dd/MM/yyyy HH:mm:ss")));
flow.add(appRegistro.createLabel("Ticket ID"));
flow.add(appRegistro.createTextBox().setName("TicketID"));
flow.add(appRegistro.createLabel("Ticket Type"));
flow.add(appRegistro.createListBox().setName("TicketType").addItem("TicketType1").addItem("ticketType2").addItem("TicketType3").addItem("TicketType4"));
flow.add(appRegistro.createLabel("Demandado por"));
flow.add(appRegistro.createListBox().setName("DemandedBy").addItem("DemandedBy1").addItem("DemandedBy1"));
flow.add(appRegistro.createLabel("Nome do Analista"));
flow.add(appRegistro.createListBox().setName("Analyst").addItem("Analyst1").addItem("Analyst1").addItem("Analyst1"));
flow.add(appRegistro.createLabel("Status"));
flow.add(appRegistro.createListBox().setName("Status").addItem("Resolvido").addItem("Em Tratamento"));
flow.add(appRegistro.createLabel("Descrição"));
flow.add(appRegistro.createTextArea().setName("Description").setSize(400, 100));
flow.add(appRegistro.createSubmitButton("Salvar"));
form.add(flow);
appRegistro.add(form);
return appRegistro;
 }

function doPost(e) {
var app=UiApp.createApplication();
var ss = SpreadsheetApp.openById("0AsXUq-Wd26qMdGFodkNqdERSc3NYaHhUQlRFeFNFQlE");
  var DataValue = e.parameter.Data;
  var TicketIDValue = e.parameter.TicketID;
  var TicketTypeValue = e.parameter.TicketType;
  var DemandedByValue = e.parameter.DemandedBy;
  var AnalystValue = e.parameter.Analyst;
  var StatusValue = e.parameter.Status;
  var DescriptionValue = e.parameter.Description;
  ss.getActiveSheet().appendRow([DataValue,TicketIDValue,TicketTypeValue,DemandedByValue,AnalystValue,StatusValue,DescriptionValue]).sort(1,false);
  return app;
  }

回答1:

I've not done much work with Spreadsheets but perhaps you could work around the restrictions, the other answerers have stated.

  • Could you write a script in your Spreadsheet to refresh itself in order to poll for new data?
  • Or could you move the form to be part of the Spreadsheet? Perhaps a button on the Spreadsheet could launch the form as a UiApp?


回答2:

It is not possible using Google Apps Script as Apps Script can not interact with browser objects.



回答3:

I think that what you are trying to accomplish is not possible due to security restrictions.