Monday, July 9, 2012

Google Apps Script: get url request parameter

Get it from doGet(e) { e.parameter.ParameterName; //or  e.parameter["param"]; }

E.g. URL: https://sites.google.com/macros/exec?service=XXXXXXXXXXXXX&test=sample_parameter


Code sample:


function doGet(e) {
  var app = UiApp.createApplication();
  var aLabel = app.createLabel("I love Apps Script!").setStyleAttribute("fontSize","16px");
  var verticalpanel = app.createVerticalPanel();
  var mybutton = app.createButton(e.parameter.test);
  verticalpanel.add(aLabel);
  verticalpanel.add(mybutton);
  app.add(verticalpanel);
  return app;
}

Subscribe to RSS Feed Follow me on Twitter!