1
votes

I'm making standalone web app in Google Apps Script. I have somekind of task flow in the app. First search something from spreadsheet, then do some selections what to do with the collected data and after that fill spreadsheet row with some userinputs. So I need to run between few states.

I'm fairly sure I don't know enough about web tech so this might be very stupid question but here it goes.

I know that the e.parameters comes from the url like this www.google.com&value=helloworld , e.parameters.value returns helloworld.

So now the problem: How do I set parameter e values in doGet(e) and call this same page or even different page/script in same script project? In otherwords how do I call self&value=helloworld ?

Is there some other way to do this? In GWT I just store everything to database and keep session in cookies. But cookies are not allowed so how to keep the state of the webapp in google apps script?

EDIT: This is how I pass the parameters for doGet(e).

function doGet(e) {
  var app = UiApp.createApplication();
  var newValue = 0;
  if(e.parameter == undefined || e.parameter.value == undefined){
    newValue = 1;
  }else{
    newValue = 1+parseInt(e.parameter.value);
  }
  var link = 'https://script.google.com/a/macros/domain.com/s/<insertidhere>/dev';
  var anchor = app.createAnchor('Next',link+'?&value='+newValue);
  anchor.setTarget('_self');
  app.add(anchor);
  var label = app.createLabel(newValue);
  app.add(label);
  return app;
}

The link format has changed a bit so instead of concatenate &value=... you need to add ? first like this ?&value1=helloworld&value2=....

Failing to use ? led me to think that there is bug and I need to use old format for the link and using that old format forbit any other than the script owner using it.

Hopefully this helps somebody to solve similar problems.

2
Changing the default link from new format to old like this works: New format: /macros/s/{service key}/exec Old format: /macros/exec?service={service key} Bugs are worst for n00bs... - user1548175

2 Answers

1
votes

You've almost answered yourself. Append the URL paramenters to the end of your web app's URL and you can access them in your script.

Let's say you have a URL like

http://script.google.com/.../exec

When you hit the URL

http://script.google.com/.../exec?value=helloworld

, inside doGet, you can read these URL parameters as

e.parameter.value;
0
votes

IMO - instead of using ? to separate multiple parameters try keeping all the values in a single anchor with some other character separator of your choice such as # since after the first ? its possibly ignoring the other one and everything afterwards. Would be great to hear back on what you find.