I'm trying to use this StackOverflow question How to pass url parameter value into string filter input in Google visualization to pass URL parameters to a Google Dashboard I created using Mogsdad's excellent writeup.
The dashboard works great, but I can't pass a parameter, e.g. ?state=Texas from the URL to use as a content filter. As soon as I call the function in my JavaScript.html file, the dashboard fails to draw:
var stateFilter = stateurl('state'); //if I use this ANYWHERE in the html file, the dashboard fails
function stateurl(variable){ //in tests this works fine on its own
var url = ScriptApp.getService().getUrl();
var vars = url.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){
return pair[1];
}else return 'Texas'
}
}
The goal of doing this is to enable my coworkers to create shortcuts to the most commonly used filters / refresh easily.
ScriptApp.getService().getUrl()contains the?character. If it does then I recommend taking a look at the conditional in your if statement.