0

I have a standalone google apps script that is used to display a data table and edit entries. The two pages are loaded using parameters at the end of the url address. I have two parameters possible {edit, entry}. The first parameter edit can only have one value "form" to tell that I need to access the edit page and the entry number is used to identify the table entry to be edited.

function doGet(e) {
  // Retrieve and process any URL parameters, as necessary.
  Logger.log(e.parameter.edit);
  Logger.log(e.parameter.entry);
  Logger.log(e.parameter);
  
  if (e.parameter.edit == "form" & e.parameter.entry) {
    Logger.log("edit");
    return EditEntry(e.parameter.entry);
    
  } else {
    Logger.log("table");
    return LoadTable();
  }  
} 

As you can see, the doGet function is straight forward and will serve two different other functions depending on the parameters. My issue is that depending on the entry value, it migh not work be well processed by the if function. For example the url with "?edit=form&entry=4444" give this log:

Infos form Infos 5555 Infos {entry=5555, edit=form} Infos edit

the url with "?edit=test&entry=5555" give this log:

Infos test Infos 5555 Infos {entry=5555, edit=form} Infos table

BUT the url with "?edit=form&entry=4444" give this log:

Infos form Infos 4444 Infos {entry=4444, edit=form} Infos table And does not serve me what I expect. As I can see from the log it is not that the entry doesn't exist (it does..) but it is not even trying to look for it. So my question is why on earth if (e.parameter.edit == "form" & e.parameter.entry) is TRUE for ?edit=test&entry=5555 and FALSE for ?edit=test&entry=4444

NB: I could discard the edit parameter as it can only take one value, and then there is no bug at all, but my development path will requireme to have other parameter to pass,so I need it...

Any help would be greatly appreciated!

1 Answer 1

1

Try this:

function doGet(e) {
  if (e.parameter.edit == "form" && e.parameter.entry) {
    return EditEntry(e.parameter.entry);
  } else {
    return LoadTable();
  }  
} 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.