SitesApp.getActivePage() always return landing page - google-apps-script

I use the following function:
function doGet(e) {
Logger.log( SitesApp.getActivePage().getName())
}
It always returns the name of the home page

This seems to be an issue with Google currently. All Google Sites are facing this issue. Please submit a bug report, and cross your fingers it'll be solved soon.
Here is an existent bug report of this issue. Please +1 it to give it more attention.

There is an older discussion about this issue here Apps Script .getActivePage() only returning "home" page
which suggests the problem can be related to using setHtmlContent() when the embedded html gets modified. There has been a recent problem with htmlbox on Google Sites for which a fix is in the process of rolling out which may have some bearing on this issue

Hi I have the same issue. My script worked on Old Google Site, but it doesn't work anymore on a new Google Site.
And the issue in this code:
var pageUrl = SitesApp.getActivePage().getUrl();
My question is almost the same: How to get URL of the current page on the New Google Site with GAS?
google.script.url.getLocation
google.script.url.getLocation(function(location) {
console.log("locations:----------------------------------------");
console.log(location);
console.log(location.parameters);
console.log(location.hash);
console.log("----------------------------------------");
});
The code above gives the next output:

Related

Google maps marker is not showing up with the error chart.apis.google.com/chart 502

I am facing an issue in Google API regarding charts.apis.google.com
and
Failed to load resource: the server responded with a status of 502 ()
GET https://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=15|acb7bf|FFFFFF 502
Due to this, my location markers are not showing up on the map.
On my live site clients are facing this issue.
I do not know what is the exact issue. Payments are clear, everything is ok.
Please suggest a quick solution for this.
I read 1 post on the google forum.
https://groups.google.com/forum/#!topic/google-visualization-api/1xT15iybzQ4
Please help me out with this issue.
Much appreciated.
Or any alternative solution.
Thanks
I had this same issue. I was using something like this below to set an different colored image for the Marker.
var pinImage = new google.maps.MarkerImage("http://www.googlemapsmarkers.com/v1/•/" + "d3d3d3" + "/");
This was reliant on googlemapsmarkers.com and is no longer working. As soon as I do not use this site to help with the MarkerImage then all is fine
Looks like this has been deprecated
https://developers.google.com/chart/image/docs/gallery/dynamic_icons
Please note that this issue has been recognized in the Issue Tracker via Issue #128905669, there is also an alternative solution offered by one of the support from Google which is to use https://www.image-charts.com/

how to refresh a google site using google apps scripts ?

My site fetches chart from spreadsheet but it is getting updated only when it is refreshed manually. Publishing on web is not working as expected. So Any method to refresh a site is much appreciated. Please do not include browser extensions or plugins or widgets, because of site audience.
After some hours struggling with this, i found a solution that worked for me.
Place this code in Templated HTML file. Then call function reloadSite() in Javascript to reload current site.
<script>
function reloadSite() {
window.top.location.href = '<?!= SitesApp.getActivePage().getUrl(); ?>';
}
</script>
Should be able to end the onSubmit() with the function that calls the Ui. You state it is doGet(), like this :
function onSubmit(e){
// Your code ...
doGet();
}

doPost stopped working google app script

I have had an HTML Service script that has worked for at least 8 months that uses a doGet for the first page and doPost of all subsequent pages.
Yesterday, when I loaded the page, the doGet works fine, pulls info from a spreadsheet and renders the the form. Regardless of what selections I make, the submit button does nothing.
I then went back to my personal gmail account, unrelated to the production account, untouched and using private dummy copies of data, where I originally coded it and that one no longer works.
I looked in the execution transcripts and it shows proper html rendering to the bottom of the first page, but nothing else.
Has doPost been retired?
I've had a working script fail recently, the fix was to force the Sandbox emulation mode to EMULATED.
The default mode WAS emulated with a caveat in the docs saying this could change.
Without seeing your code I'm not sure if that is relevant or not....
function doGet() {
var html = HtmlService.createTemplateFromFile("FormHtml");
html = html.evaluate();
html.setSandboxMode(HtmlService.SandboxMode.EMULATED);
return html;
}

Automatically Redirecting to a Page

Inside a button click handler, I'm creating a new web page like so:
var page = SitesApp.getPageByUrl(url).createPageFromTemplate(title, name, template);
and I want to redirect the user automatically to that page.
I wasn't able to find much information, can this be done?
Corey G's answer worked for me, but the problem is that the web page that I was redirecting was embedded into an iframe in the response of the GAS, so the real URL in the web browser was the script's one.
This is what actually worked for me:
function doGet() {
return HtmlService.createHtmlOutput(
"<script>window.top.location.href='https://example.com';</script>"
);
}
This similar Q/A helped me to solve it.
Hope it helps.
This cannot be done in UiApp but it's doable in HtmlService:
function doGet() {
return HtmlService.createHtmlOutput(
"<form action='http://www.google.com' method='get' id='foo'></form>" +
"<script>document.getElementById('foo').submit();</script>");
}
This should be easier; please file a feature request in the issue tracker and we will see how we can make this more pleasant.
(Edit: To be clear, there's no way to do this from a UiApp callback; your entire app would have to be using HtmlService for this to work.)

FB.Canvas.setSize stopped working (today?)

This method seems to have stopped working.
App code was tested thoroughly last week and all was well. This morning...scrollbars are appearing on our page tab apps.
Example:
http://www.facebook.com/HondaPowersports/app_329359370439338
Very simple code on this page - it is all static HTML with just one FB method call:
window.fbAsyncInit = function() {
FB.Canvas.setSize({ width: 810, height: 975 });
}
Anyone else with this same problem? Any ideas?
According to the documentation (FB.Canvas.setSize):
Note: this method is only enabled when Canvas Height is set to "Settable (Default: 800px)" in the Developer App.
Has someone modified the settings of your Facebook app? If it's not configured as stated above then it stops working.
it seems to me it is deprecated and you have to use setAutoGrow... not sure , take a look :)
Related bug: http://developers.facebook.com/bugs/322561887802154