I have created a Google Apps script and I have a question about passing a variable to the click handler. The script is published as a Web App and is accessed by an HTML link in an email (its an approve/deny form for a business request). When someone submits a form, an email is sent to the approver who when clicks on the approve link. This link contains the following variables:
?status=enteredInCC&rowNum=9
So when they click on the link the script is launched, and it enters the function doGet(e) block and where relevant code is:
var app = UiApp.createApplication();
var grid = app.createGrid(1, 2);
var label = app.createLabel('Please enter the item\'s PLU:')
var input = app.createTextBox().setId("input").setName("input");
grid.setWidget(0, 0, label);
grid.setWidget(0, 1, input);
var handler = app.createServerHandler("retrieveInput").addCallbackElement(input);
var button = app.createButton("OK", handler);
var panel = app.createVerticalPanel().setId("panel")
panel.add(grid);
panel.add(button);
app.add(panel);
return app;
Which leads to the click handler:
function retrieveInput(e){
var input = e.parameter.input;
var app = UiApp.getActiveApplication();
var panel = app.getElementById('panel');
panel.clear();
app.add(app.createHTML('<h2>The request has been updated. You can close this window.</h2>'))
app.close()
return app;
}
And all of that runs great. However, earlier in the doGet(e) function some information was collected from the URL and stored in variables. Now in retrieveInput(e) I'm needing to access those variables to make some updates to the Spreadsheet (just after panel.clear()). Any ideas?