Fixed
Status Update
Comments
ph...@g-workplace.com <ph...@g-workplace.com> #2
We are also having a problem with startup script in an App Maker app which has worked fine for months and now suddenly throws this error and refuses to load the app.
The startup script is:
//hide the default scroll bar of the Apps Script iFrame
parent.document.getElementById('userHtmlFrame').style.overflowY='hidden';
// Load the Google API
var clientId = "ourclientid.apps.googleusercontent.com ";
// Scope to use to access user's drive.
var scope = ['https://www.googleapis.com/auth/drive' ];
var auth = {
'client_id': clientId,
'scope': scope,
'immediate': true
};
function handleAuthResult(authResult) {
if (authResult && !authResult.error) {
console.log('Google client api library authorized');
} else {
auth.immediate = false;
window.gapi.auth.authorize(auth, handleAuthResult);
}
}
function onPickerApiLoad() {
// Continues loading the app
console.log('Picker API loaded');
app.datasources.Configuration.load(function(){
console.log('Configuration datasource loaded, resuming application load');
loader.resumeLoad();
});
}
function onAuthApiLoad() {
// auth is loaded so authorize
console.log('Auth API loaded');
window.gapi.auth.authorize(auth, handleAuthResult);
}
// Suspends app loading until after the Google Client API
// and the Configuration datasource loads.
loader.suspendLoad();
// Defines a callback function, for the client API. It must be global,
// so it's explicitly attached to the window object.
window.apiLoaded = function() {
try {
console.log('Google API loaded. Loading auth & picker');
gapi.load('auth', {'callback' : onAuthApiLoad});
gapi.load('picker', {'callback': onPickerApiLoad});
} catch (e) {
console.log(e.message);
console.log('Google client api library retry authentication');
window.setTimeout(apiLoaded, 500);
}
};
var script = document.createElement("script");
script.setAttribute("type", "text/javascript");
// Specifies the name of the callback function in the "onload"
// parameter of the URL.
var url = "https://apis.google.com/js/api.js?onload=apiLoaded ";
script.setAttribute("src", url);
document.getElementsByTagName("head")[0].appendChild(script);
Here is the error thrown to the console:
Fri Apr 07 10:41:16 GMT+200 2017 com.google.apps.appmaker.client.script.ScriptEngine
SEVERE: Native Exception: (TypeError) : Cannot read property 'run' of undefined
com.google.gwt.core.client.JavaScriptException: (TypeError) : Cannot read property 'run' of undefined
at Unknown.ro(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.ho(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.LP(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.gQ(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.xu(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.Ku(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.eq(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.Op(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.lq(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.Nac(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.Mac(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.Rac(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.vac(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.Pgc(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.Tgc(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.Mgc(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.lH(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.eW(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.yX(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.MY(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.pZ(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.MY(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.pZ(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.MY(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.pZ(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.MY(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.lIb(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.MY(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.pZ(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.VI(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.UI(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.TI(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.SI(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.eJ(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.Yi(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.dJ(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.aJ(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.cJ(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.cb(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.eval(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.j8c(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.m8c(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.eval(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.resumeLoad(https://www.gstatic.com/appmaker/gwt/20170328_RC00/clientScriptsContext.js )
at Unknown.onPickerApiLoad(<anonymous>)
at Unknown.anonymous(https://apis.google.com/js/api.js?onload=apiLoaded )
at Unknown.ca(https://apis.google.com/js/api.js?onload=apiLoaded )
at Unknown.b(https://apis.google.com/js/api.js?onload=apiLoaded )
at Unknown.anonymous(Unknown)
at Unknown.c(https://apis.google.com/js/api.js?onload=apiLoaded )
at Unknown.anonymous(https://apis.google.com/js/api.js?onload=apiLoaded )
at Unknown.ca(https://apis.google.com/js/api.js?onload=apiLoaded )
at Unknown.b(https://apis.google.com/js/api.js?onload=apiLoaded )
at Unknown.Y.r.(Unknown)
at Unknown.Y.x.(Unknown)
at Unknown.anonymous(https://apis.google.com/_/scs/apps-static/_/js/k=oz.gapi.en.jCuyT93K8tU.O/m …sv=1/d=1/ed=1/am=EQ/rs=AGLTcCNfbiy4fP8hVPJETMCwd-AQKoMXuw/cb=gapi.loaded_0)
We also have apps script apps in production which are displaying the same symptoms
This is potentially a big issue for us, please advise
Phil Thain
G-workplace
The startup script is:
//hide the default scroll bar of the Apps Script iFrame
parent.document.getElementById('userHtmlFrame').style.overflowY='hidden';
// Load the Google API
var clientId = "
// Scope to use to access user's drive.
var scope = ['
var auth = {
'client_id': clientId,
'scope': scope,
'immediate': true
};
function handleAuthResult(authResult) {
if (authResult && !authResult.error) {
console.log('Google client api library authorized');
} else {
auth.immediate = false;
window.gapi.auth.authorize(auth, handleAuthResult);
}
}
function onPickerApiLoad() {
// Continues loading the app
console.log('Picker API loaded');
app.datasources.Configuration.load(function(){
console.log('Configuration datasource loaded, resuming application load');
loader.resumeLoad();
});
}
function onAuthApiLoad() {
// auth is loaded so authorize
console.log('Auth API loaded');
window.gapi.auth.authorize(auth, handleAuthResult);
}
// Suspends app loading until after the Google Client API
// and the Configuration datasource loads.
loader.suspendLoad();
// Defines a callback function, for the client API. It must be global,
// so it's explicitly attached to the window object.
window.apiLoaded = function() {
try {
console.log('Google API loaded. Loading auth & picker');
gapi.load('auth', {'callback' : onAuthApiLoad});
gapi.load('picker', {'callback': onPickerApiLoad});
} catch (e) {
console.log(e.message);
console.log('Google client api library retry authentication');
window.setTimeout(apiLoaded, 500);
}
};
var script = document.createElement("script");
script.setAttribute("type", "text/javascript");
// Specifies the name of the callback function in the "onload"
// parameter of the URL.
var url = "
script.setAttribute("src", url);
document.getElementsByTagName("head")[0].appendChild(script);
Here is the error thrown to the console:
Fri Apr 07 10:41:16 GMT+200 2017 com.google.apps.appmaker.client.script.ScriptEngine
SEVERE: Native Exception: (TypeError) : Cannot read property 'run' of undefined
com.google.gwt.core.client.JavaScriptException: (TypeError) : Cannot read property 'run' of undefined
at Unknown.ro(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.ho(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.LP(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.gQ(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.xu(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.Ku(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.eq(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.Op(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.lq(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.Nac(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.Mac(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.Rac(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.vac(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.Pgc(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.Tgc(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.Mgc(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.lH(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.eW(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.yX(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.MY(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.pZ(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.MY(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.pZ(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.MY(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.pZ(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.MY(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.lIb(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.MY(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.pZ(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.VI(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.UI(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.TI(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.SI(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.eJ(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.Yi(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.dJ(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.aJ(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.cJ(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.cb(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.eval(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.j8c(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.m8c(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.eval(com.google.apps.appmaker.AppMakerGwt-0.js)
at Unknown.resumeLoad(
at Unknown.onPickerApiLoad(<anonymous>)
at Unknown.anonymous(
at Unknown.ca(
at Unknown.b(
at Unknown.anonymous(Unknown)
at Unknown.c(
at Unknown.anonymous(
at Unknown.ca(
at Unknown.b(
at Unknown.Y.r.(Unknown)
at Unknown.Y.x.(Unknown)
at Unknown.anonymous(
We also have apps script apps in production which are displaying the same symptoms
This is potentially a big issue for us, please advise
Phil Thain
G-workplace
gu...@hmw.gr.jp <gu...@hmw.gr.jp> #3
With the same problem, all the scripts used in business are suspended from today.
When I looked it up, I could do it without any problems for running with the code google.script.run.kinoko ().
However, if you add a handler, such as google.script.run.withSuccessHandler (onSuccess) .kinoko ("shimeji"), and attaching arguments to the function to be executed, this trouble occurred.
However, even if it is a similar function, if there is no argument, it can be executed and the value can be obtained from the server side.
Therefore, if you display the code like the following in the sidebar or HTML dialog instead of the web application and pushing the button, it causes a problem.
Because it is an extremely fatal error, please change it with top priority.
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons.css ">
<script type="text/javascript" src="https://apis.google.com/js/api.js "></script>
<script type="text/javascript">
var DEVELOPER_KEY = 'developerkey';
var DIALOG_DIMENSIONS = {width: 750, height: 480};
var pickerApiLoaded = false;
gapi.load('picker', {'callback': function() {
pickerApiLoaded = true;
}});
//💀The part where the problem is occurring. There is no problem with the code itself.
function getOAuthToken() {
google.script.run.withSuccessHandler(createPicker).withFailureHandler(showError).getOAuthToken();
}
function createPicker(token) {
if (pickerApiLoaded && token) {
var docsView = new google.picker.DocsView()
.setIncludeFolders(true)
.setMimeTypes('application/vnd.google-apps.folder')
//.setParent("parentfolderid")
.setSelectFolderEnabled(true);
var picker = new google.picker.PickerBuilder()
.setLocale('ja')
.addView(docsView)
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.hideTitleBar()
.setOAuthToken(token)
.setOrigin('https://docs.google.com ')
.setDeveloperKey(DEVELOPER_KEY)
.setCallback(pickerCallback)
.setSize(DIALOG_DIMENSIONS.width - 2,
DIALOG_DIMENSIONS.height - 2)
.build();
picker.setVisible(true);
} else {
showError('Unable to load the file picker.');
}
}
function pickerCallback(data) {
var action = data[google.picker.Response.ACTION];
if (action == google.picker.Action.PICKED) {
var doc = data[google.picker.Response.DOCUMENTS][0];
var id = doc[google.picker.Document.ID ];
var url = doc[google.picker.Document.URL];
var title = doc[google.picker.Document.NAME ];
document.getElementById('result').innerHTML =
'<b>You chose:</b><br>Name: <a href="' + url + '">' + title + '</a><br>ID: ' + id;
google.script.run.telepon3(id,title);
} else if (action == google.picker.Action.CANCEL) {
document.getElementById('result').innerHTML = 'Picker canceled.';
}
}
function showError(message) {
document.getElementById('result').innerHTML = 'Error: ' + message;
}
</script>
<div>
<button class="action" onclick='getOAuthToken()'>picker load</button>
<p id='result'></p>
</div>
When I looked it up, I could do it without any problems for running with the code google.script.run.kinoko ().
However, if you add a handler, such as google.script.run.withSuccessHandler (onSuccess) .kinoko ("shimeji"), and attaching arguments to the function to be executed, this trouble occurred.
However, even if it is a similar function, if there is no argument, it can be executed and the value can be obtained from the server side.
Therefore, if you display the code like the following in the sidebar or HTML dialog instead of the web application and pushing the button, it causes a problem.
Because it is an extremely fatal error, please change it with top priority.
<link rel="stylesheet" href="
<script type="text/javascript" src="
<script type="text/javascript">
var DEVELOPER_KEY = 'developerkey';
var DIALOG_DIMENSIONS = {width: 750, height: 480};
var pickerApiLoaded = false;
gapi.load('picker', {'callback': function() {
pickerApiLoaded = true;
}});
//💀The part where the problem is occurring. There is no problem with the code itself.
function getOAuthToken() {
google.script.run.withSuccessHandler(createPicker).withFailureHandler(showError).getOAuthToken();
}
function createPicker(token) {
if (pickerApiLoaded && token) {
var docsView = new google.picker.DocsView()
.setIncludeFolders(true)
.setMimeTypes('application/vnd.google-apps.folder')
//.setParent("parentfolderid")
.setSelectFolderEnabled(true);
var picker = new google.picker.PickerBuilder()
.setLocale('ja')
.addView(docsView)
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.hideTitleBar()
.setOAuthToken(token)
.setOrigin('
.setDeveloperKey(DEVELOPER_KEY)
.setCallback(pickerCallback)
.setSize(DIALOG_DIMENSIONS.width - 2,
DIALOG_DIMENSIONS.height - 2)
.build();
picker.setVisible(true);
} else {
showError('Unable to load the file picker.');
}
}
function pickerCallback(data) {
var action = data[google.picker.Response.ACTION];
if (action == google.picker.Action.PICKED) {
var doc = data[google.picker.Response.DOCUMENTS][0];
var id = doc[
var url = doc[google.picker.Document.URL];
var title = doc[
document.getElementById('result').innerHTML =
'<b>You chose:</b><br>Name: <a href="' + url + '">' + title + '</a><br>ID: ' + id;
google.script.run.telepon3(id,title);
} else if (action == google.picker.Action.CANCEL) {
document.getElementById('result').innerHTML = 'Picker canceled.';
}
}
function showError(message) {
document.getElementById('result').innerHTML = 'Error: ' + message;
}
</script>
<div>
<button class="action" onclick='getOAuthToken()'>picker load</button>
<p id='result'></p>
</div>
to...@yle.fi <to...@yle.fi> #4
I'll contribute to this thread with my code.
Nyt tool is calling app scripts from the company's internal Google Site.
Everything has been working fine for couple years but yesterday I got this error in the console:
"Uncaught TypeError: Cannot read property 'run' of undefined"
Cause of this points to JS lines that runs the google script:
google.script.run.withSuccessHandler(loadExcel).withFailureHandler(showError).getOAuthToken();
Toni Asola
Yle production & design
This part creates the html page for UI:
function getOAuthToken() {
DriveApp.getRootFolder();
return ScriptApp.getOAuthToken();
}
function doGet() {
var html = HtmlService.createHtmlOutputFromFile('valitsin')
.setSandboxMode(HtmlService.SandboxMode.IFRAME).setWidth(600).setHeight(425);
return html;
}
And this is the 'valitsin.html' that has buttons to run separate google scripts:
<!DOCTYPE html>
<html>
<body>
<head>
<base target="_top">
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css ">
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons.css ">
<script src="https://apis.google.com/js/api.js?onload=onApiLoad "></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.js "></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.js "></script>
<script src="https://malsup.github.io/jquery.blockUI.js "></script>
<script type="text/javascript">
var DEVELOPER_KEY = 'Ionlyseethisbutitsthere';
var DIALOG_DIMENSIONS = {width: 600, height: 425};
var pickerApiLoaded = false;
var btn;
var month;
var year;
var jaksot = [new Date('Jan 12 2015'), new Date('Feb 02 2015'),
new Date('Feb 23 2015'), new Date('Mar 16 2015'), new Date('Apr 06 2015'), new Date('Apr 27 2015'), new Date('May 18 2015'),
new Date('Jun 08 2015'), new Date('Jun 29 2015'), new Date('Jul 20 2015'), new Date('Aug 10 2015'), new Date('Aug 31 2015'),
new Date('Sep 21 2015'), new Date('Oct 12 2015'), new Date('Nov 02 2015'), new Date('Nov 23 2015'), new Date('Dec 14 2015'),
new Date('Jan 04 2016'), new Date('Jan 25 2016'), new Date('Feb 15 2016'), new Date('Mar 07 2016'), new Date('Mar 28 2016'),
new Date('Apr 18 2016'), new Date('May 09 2016'), new Date('May 30 2016'), new Date('Jun 20 2016'), new Date('Jul 11 2016'),
new Date('Aug 01 2016'), new Date('Aug 22 2016'), new Date('Sep 12 2016'), new Date('Oct 03 2016'), new Date('Oct 24 2016'),
new Date('Nov 14 2016'), new Date('Dec 05 2016'), new Date('Dec 26 2016'), new Date('Jan 16 2017'), new Date('Feb 06 2017'),
new Date('Feb 27 2017'), new Date('Mar 20 2017'), new Date('Apr 10 2017'), new Date('May 01 2017'), new Date('May 22 2017'),
new Date('Jun 12 2017'), new Date('Jul 03 2017'), new Date('Jul 24 2017'), new Date('Aug 14 2017'), new Date('Sep 04 2017'),
new Date('Sep 25 2017'), new Date('Oct 16 2017'), new Date('Nov 06 2017'), new Date('Nov 27 2017'), new Date('Dec 18 2017')];
gapi.load('picker', {'callback': function() {
pickerApiLoaded = true;
}});
function toiminnot(btn) {
switch (btn)
{
case "1": // Ladataan excel, jonka tiedot siirretään kalentereihin
google.script.run.withSuccessHandler(loadExcel).withFailureHandler(showError).getOAuthToken();
break
case "2": // Tehdään uusi pohja
$('div.blockMe').block({message: null,overlayCSS: { backgroundColor: '#fff' }});
document.getElementById('result').innerHTML ='Tehdään uusi vuorolistapohja.';
google.script.run.withSuccessHandler(uudenvalmistelu).withFailureHandler(showError).doPohja($("#jaksu").val());
break
case "3": // Päivitä pohja
google.script.run.withSuccessHandler(updateTAA).withFailureHandler(showError).getOAuthToken();
break
case "4": // Tee CSV
google.script.run.withSuccessHandler(doCSV).withFailureHandler(showError).getOAuthToken();
break
case "5": // Liitetään listan tiedot kalenterikutsuihin aka julkaisu
google.script.run.withSuccessHandler(doJulkaisu).withFailureHandler(showError).getOAuthToken();
break
case "6": // Toteumat Sheet
$('div.blockMe').block({message: null,overlayCSS: { backgroundColor: '#fff' }});
document.getElementById('result').innerHTML ='Tehdään toteuma-sheet TVS-kansioon.';
google.script.run.withSuccessHandler(hyvinMeni).withFailureHandler(showError).doToteuma($("#startDate").val());
break
case "7": // Kuunnelma toteumat Sheet
$('div.blockMe').block({message: null,overlayCSS: { backgroundColor: '#fff' }});
document.getElementById('result').innerHTML ='Tehdään kuunnelmatoteuma-sheet TVS-kansioon.';
google.script.run.withSuccessHandler(hyvinMeni).withFailureHandler(showError).doStudioToteuma($("#startDate").val());
break
case "8": // Tee tai päivitä Ceiton TAA-pohja
google.script.run.withSuccessHandler(doCeiton).withFailureHandler(showError).getOAuthToken();
break
case "9": // Ceiton TAA-pohjasta CSV
google.script.run.withSuccessHandler(doCeitonCSV).withFailureHandler(showError).getOAuthToken();
break
}
}
// 1. Lataa excel kalenteriin
function loadExcel(token) { // Näkymä .setParent('TVS')
if (pickerApiLoaded && token) {
var picker = new google.picker.PickerBuilder()
.addView(new google.picker.DocsUploadView().setParent('0B3faoEDlK5jWT1lxZnQtU3lPNWs'))
//.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.hideTitleBar()
.setLocale('fi')
.setOrigin('https://sites.google.com/a/yle.fi/asola-oppii-ja-erehtyy/TVS ')
.setOAuthToken(token)
.setDeveloperKey(DEVELOPER_KEY)
.setCallback(loadExcelCallback)
.setSize(DIALOG_DIMENSIONS.width - 2,
DIALOG_DIMENSIONS.height - 2)
.build();
picker.setVisible(true);
} else {
showError('Teidostovalitsimen lataus epäonnistui.');
}
}
function loadExcelCallback(data) {
var action = data[google.picker.Response.ACTION];
if (action == google.picker.Action.PICKED) {
var doc = data[google.picker.Response.DOCUMENTS][0];
var id = doc[google.picker.Document.ID ];
google.script.run.withSuccessHandler(excelkalenteriin).withFailureHandler(showError).xlsxToSheet(id); // Ensin excel pitää muuttaa Sheetiksi
} else if (action == google.picker.Action.CANCEL) {
document.getElementById('result').innerHTML = 'Valinta keskeytettiin.';
}
}
function excelkalenteriin(id){
$('div.blockMe').block({message: null,overlayCSS: { backgroundColor: '#fff' }});
document.getElementById('result').innerHTML ='Ajetaan varaukset kalenteriin.';
google.script.run.withSuccessHandler(hyvinMeni).withFailureHandler(showError).fromExcel(id); // Nyt vasta Sheet kalenteriin
}
function uudenvalmistelu(id){
document.getElementById('result').innerHTML ='Päivitetään uusi listapohja';
google.script.run.withSuccessHandler(hyvinMeni).withFailureHandler(showError).updateTAA(id); // 2. Uusi TAA-pohja saa vuorot
}
function updateTAA(token) { // .setParent('0B3faoEDlK5jWRlctdUtFRVBheWM') 3. Käyttäjän valitseman TAA-pohjan päivitys
if (pickerApiLoaded && token) {
var picker = new google.picker.PickerBuilder()
.disableFeature(google.picker.Feature.NAV_HIDDEN)
.addView(new google.picker.DocsView(google.picker.ViewId.SPREADSHEETS)
.setParent('0B3faoEDlK5jWT1lxZnQtU3lPNWs')
.setIncludeFolders(true)
.setSelectFolderEnabled(true))
.setOrigin('https://sites.google.com/a/yle.fi/asola-oppii-ja-erehtyy/TVS ')
.hideTitleBar()
.setLocale('fi')
.setOAuthToken(token)
.setDeveloperKey(DEVELOPER_KEY)
.setCallback(updateTAACallback)
.setSize(DIALOG_DIMENSIONS.width - 2,
DIALOG_DIMENSIONS.height - 2)
.build();
picker.setVisible(true);
} else {
showError('Tiedostovalitsimen lataus epäonnistui.');
}
}
function updateTAACallback(data) {
var action = data[google.picker.Response.ACTION];
if (action == google.picker.Action.PICKED) {
var doc = data[google.picker.Response.DOCUMENTS][0];
var id = doc[google.picker.Document.ID ];
var title = doc[google.picker.Document.NAME ];
$('div.blockMe').block({message: null,overlayCSS: { backgroundColor: '#fff' }});
document.getElementById('result').innerHTML = 'Päivitetään lista :'+ title;
google.script.run.withSuccessHandler(hyvinMeni).withFailureHandler(showError).updateTAA(id);
} else if (action == google.picker.Action.CANCEL) {
document.getElementById('result').innerHTML = 'Valinta keskeytettiin.';
}
}
function doCSV(token) { // 4. CSV-tiedoston tekeminen
if (pickerApiLoaded && token) {
var picker = new google.picker.PickerBuilder()
.addView(new google.picker.DocsView(google.picker.ViewId.SPREADSHEETS)
.setParent('0B3faoEDlK5jWT1lxZnQtU3lPNWs')
.setIncludeFolders(true)
.setSelectFolderEnabled(true))
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.setOrigin('https://sites.google.com/a/yle.fi/asola-oppii-ja-erehtyy/TVS ')
.hideTitleBar()
.setLocale('fi')
.setOAuthToken(token)
.setDeveloperKey(DEVELOPER_KEY)
.setCallback(doCSVCallback)
.setSize(DIALOG_DIMENSIONS.width - 2,
DIALOG_DIMENSIONS.height - 2)
.build();
picker.setVisible(true);
} else {
showError('Tiedostovalitsimen lataus epäonnistui.');
}
}
function doCSVCallback(data) {
var action = data[google.picker.Response.ACTION];
if (action == google.picker.Action.PICKED) {
var doc = data[google.picker.Response.DOCUMENTS][0];
var id = doc[google.picker.Document.ID ];
var title = doc[google.picker.Document.NAME ];
$('div.blockMe').block({message: null,overlayCSS: { backgroundColor: '#fff' }});
document.getElementById('result').innerHTML = 'Tehdään CVS-tiedosto Hera-ajoa varten:'+ title;
google.script.run.withSuccessHandler(hyvinMeni).withFailureHandler(showError).toCSV(id);
} else if (action == google.picker.Action.CANCEL) {
document.getElementById('result').innerHTML = 'Valinta keskeytettiin.';
}
}
function doJulkaisu(token) { // 5. Vuorojen julkaisu kalentereihin
if (pickerApiLoaded && token) {
var picker = new google.picker.PickerBuilder()
.addView(new google.picker.DocsView(google.picker.ViewId.SPREADSHEETS)
.setParent('0BxT7kV9T1noJYjNPb2RybkExc0U') // Katsotaan aluksi vain Julkaistuts-kansioon.
.setIncludeFolders(true)
.setSelectFolderEnabled(true))
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.setOrigin('https://sites.google.com/a/yle.fi/asola-oppii-ja-erehtyy/TVS ')
.hideTitleBar()
.setLocale('fi')
.setOAuthToken(token)
.setDeveloperKey(DEVELOPER_KEY)
.setCallback(doJulkaisuCallback)
.setSize(DIALOG_DIMENSIONS.width - 2,
DIALOG_DIMENSIONS.height - 2)
.build();
picker.setVisible(true);
} else {
showError('Tiedostovalitsimen lataus epäonnistui.');
}
}
function doJulkaisuCallback(data) {
var action = data[google.picker.Response.ACTION];
if (action == google.picker.Action.PICKED) {
var doc = data[google.picker.Response.DOCUMENTS][0];
var id = doc[google.picker.Document.ID ];
var title = doc[google.picker.Document.NAME ];
$('div.blockMe').block({message: null,overlayCSS: { backgroundColor: '#fff' }});
document.getElementById('result').innerHTML = 'Julkaistaan vuorot listalta: '+ title;
google.script.run.withSuccessHandler(doVPVL).withFailureHandler(showError).toCAL(id);
} else if (action == google.picker.Action.CANCEL) {
document.getElementById('result').innerHTML = 'Valinta keskeytettiin.';
}
}
function doVPVL(id){ // Vielä VPVL -kalenteri
document.getElementById('result').innerHTML ='Vielä VP,VL,TV,yms. tiedot kalenteriin.';
google.script.run.withSuccessHandler(hyvinMeni).withFailureHandler(showError).doVPVL(id);
}
function doCeiton(token) { // 8. Pickerille heitetään Ceitonin xls
if (pickerApiLoaded && token) {
var picker = new google.picker.PickerBuilder()
.addView(new google.picker.DocsUploadView().setParent('0B3faoEDlK5jWT1lxZnQtU3lPNWs'))
//.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.hideTitleBar()
.setLocale('fi')
.setOrigin('https://sites.google.com/a/yle.fi/asola-oppii-ja-erehtyy/TVS ')
.setOAuthToken(token)
.setDeveloperKey(DEVELOPER_KEY)
.setCallback(loadtoCeiton)
.setSize(DIALOG_DIMENSIONS.width - 2,
DIALOG_DIMENSIONS.height - 2)
.build();
picker.setVisible(true);
} else {
showError('Tiedostovalitsimen lataus epäonnistui.');}
}
function loadtoCeiton(data) { // Pickeriltä saadaan data-objekti
var action = data[google.picker.Response.ACTION];
if (action == google.picker.Action.PICKED) {
var doc = data[google.picker.Response.DOCUMENTS][0];
var id = doc[google.picker.Document.ID ];
$('div.blockMe').block({message: null,overlayCSS: { backgroundColor: '#fff' }});
document.getElementById('result').innerHTML ='CEITON-Liste wird als Arbeitszeit Autonomie-Liste geändert werden.';
google.script.run.withSuccessHandler(hyvinMeni).withFailureHandler(showError).CeitonxlsxToSheet(id); // Rullataan excelistä TAA-pohja.
} else if (action == google.picker.Action.CANCEL) {
document.getElementById('result').innerHTML = 'Valinta keskeytettiin.';
}
}
function doCeitonCSV(token) { // 9. Ceiton CSV-tiedoston tekeminen
if (pickerApiLoaded && token) {
var picker = new google.picker.PickerBuilder()
.addView(new google.picker.DocsView(google.picker.ViewId.SPREADSHEETS)
.setParent('0B3faoEDlK5jWT1lxZnQtU3lPNWs')
.setIncludeFolders(true)
.setSelectFolderEnabled(true))
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.setOrigin('https://sites.google.com/a/yle.fi/asola-oppii-ja-erehtyy/TVS ')
.hideTitleBar()
.setLocale('fi')
.setOAuthToken(token)
.setDeveloperKey(DEVELOPER_KEY)
.setCallback(doCeitonCSVCallback)
.setSize(DIALOG_DIMENSIONS.width - 2,
DIALOG_DIMENSIONS.height - 2)
.build();
picker.setVisible(true);
} else {
showError('Tiedostovalitsimen lataus epäonnistui.');
}
}
function doCeitonCSVCallback(data) {
var action = data[google.picker.Response.ACTION];
if (action == google.picker.Action.PICKED) {
var doc = data[google.picker.Response.DOCUMENTS][0];
var id = doc[google.picker.Document.ID ];
var title = doc[google.picker.Document.NAME ];
$('div.blockMe').block({message: null,overlayCSS: { backgroundColor: '#fff' }});
document.getElementById('result').innerHTML = 'Ceiton CVS-tiedosto Hera-ajoa varten:'+ title;
google.script.run.withSuccessHandler(hyvinMeni).withFailureHandler(showError).CeitontoCSV(id);
} else if (action == google.picker.Action.CANCEL) {
document.getElementById('result').innerHTML = 'Valinta keskeytettiin.';
}
}
function hyvinMeni(){ // Kaikki meni OK
$('div.blockMe').unblock();
document.getElementById('result').innerHTML ='';
alert('Homma valmis!');
}
function showError(message) { // Jokin meni pieleen
$('div.blockMe').unblock();
document.getElementById('result').innerHTML = '';
alert('Virhe: ' + message);
}
function jaksota(){ // Jaksot ListBoksiin
var select = document.getElementById('jaksu');
var i;
for (i = 0; i < jaksot.length; i++) {
var el = document.createElement("option");
el.textContent = jaksot[i].toLocaleDateString();
el.value = jaksot[i];
select.appendChild(el);
}}
window.onload = jaksota;
$(function() { // Jaksonvalitsin
$('.date-picker').datepicker( {
changeMonth: true,
changeYear: true,
showButtonPanel: true,
dateFormat: 'm/yy',
maxDate: "+1M",
minDate: "-12M",
onClose: function(dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year, month, 1));
}
});
});
</script>
<style>
.ui-datepicker-calendar {
display: none;
}
.ui-datepicker {
width: 210px;
height: auto;
margin: 5px auto 0;
font: 9pt Arial, sans-serif;
-webkit-box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, .5);
-moz-box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, .5);
box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, .5);
}
</style>
</head>
<div class="blockMe">
<button style="width:210px" onclick='toiminnot("1")'>Lataa excelistä tiedot kalentereihin</button><br><br>
<select id="jaksu" dir="rtl" name="D1"></select>
<button style="width:120px" onclick='toiminnot("2")'>Luo uusi TAA-lista</button><br><br>
<button style="width:210px" onclick='toiminnot("3")'>Päivitä TAA-lista</button><br><br>
<button style="width:210px" onclick='toiminnot("4")'>Tee TAA-listasta Hera-tiedosto</button><br><br>
<button style="width:210px" onclick='toiminnot("5")'>Julkaise TAA-listan vuorot</button><br><br>
<input style="width:205px" name="startDate" id="startDate" class="date-picker" value="1/2015" /><br>
<button style="width:210px" onclick='toiminnot("6")'>Tarkkailutoteumat</button><br>
<button style="width:210px" onclick='toiminnot("7")'>Kuunnelmatoteumat</button>
<button style="width:210px" onclick='toiminnot("8")'>Aus Ceiton</button>
<button style="width:210px" onclick='toiminnot("9")'>Nach CSV</button>
</div>
<div>
<p id='result'></p>
</div>
</body>
</html>
Nyt tool is calling app scripts from the company's internal Google Site.
Everything has been working fine for couple years but yesterday I got this error in the console:
"Uncaught TypeError: Cannot read property 'run' of undefined"
Cause of this points to JS lines that runs the google script:
google.script.run.withSuccessHandler(loadExcel).withFailureHandler(showError).getOAuthToken();
Toni Asola
Yle production & design
This part creates the html page for UI:
function getOAuthToken() {
DriveApp.getRootFolder();
return ScriptApp.getOAuthToken();
}
function doGet() {
var html = HtmlService.createHtmlOutputFromFile('valitsin')
.setSandboxMode(HtmlService.SandboxMode.IFRAME).setWidth(600).setHeight(425);
return html;
}
And this is the 'valitsin.html' that has buttons to run separate google scripts:
<!DOCTYPE html>
<html>
<body>
<head>
<base target="_top">
<link rel="stylesheet" href="
<link rel="stylesheet" href="
<script src="
<script src="
<script src="
<script src="
<script type="text/javascript">
var DEVELOPER_KEY = 'Ionlyseethisbutitsthere';
var DIALOG_DIMENSIONS = {width: 600, height: 425};
var pickerApiLoaded = false;
var btn;
var month;
var year;
var jaksot = [new Date('Jan 12 2015'), new Date('Feb 02 2015'),
new Date('Feb 23 2015'), new Date('Mar 16 2015'), new Date('Apr 06 2015'), new Date('Apr 27 2015'), new Date('May 18 2015'),
new Date('Jun 08 2015'), new Date('Jun 29 2015'), new Date('Jul 20 2015'), new Date('Aug 10 2015'), new Date('Aug 31 2015'),
new Date('Sep 21 2015'), new Date('Oct 12 2015'), new Date('Nov 02 2015'), new Date('Nov 23 2015'), new Date('Dec 14 2015'),
new Date('Jan 04 2016'), new Date('Jan 25 2016'), new Date('Feb 15 2016'), new Date('Mar 07 2016'), new Date('Mar 28 2016'),
new Date('Apr 18 2016'), new Date('May 09 2016'), new Date('May 30 2016'), new Date('Jun 20 2016'), new Date('Jul 11 2016'),
new Date('Aug 01 2016'), new Date('Aug 22 2016'), new Date('Sep 12 2016'), new Date('Oct 03 2016'), new Date('Oct 24 2016'),
new Date('Nov 14 2016'), new Date('Dec 05 2016'), new Date('Dec 26 2016'), new Date('Jan 16 2017'), new Date('Feb 06 2017'),
new Date('Feb 27 2017'), new Date('Mar 20 2017'), new Date('Apr 10 2017'), new Date('May 01 2017'), new Date('May 22 2017'),
new Date('Jun 12 2017'), new Date('Jul 03 2017'), new Date('Jul 24 2017'), new Date('Aug 14 2017'), new Date('Sep 04 2017'),
new Date('Sep 25 2017'), new Date('Oct 16 2017'), new Date('Nov 06 2017'), new Date('Nov 27 2017'), new Date('Dec 18 2017')];
gapi.load('picker', {'callback': function() {
pickerApiLoaded = true;
}});
function toiminnot(btn) {
switch (btn)
{
case "1": // Ladataan excel, jonka tiedot siirretään kalentereihin
google.script.run.withSuccessHandler(loadExcel).withFailureHandler(showError).getOAuthToken();
break
case "2": // Tehdään uusi pohja
$('div.blockMe').block({message: null,overlayCSS: { backgroundColor: '#fff' }});
document.getElementById('result').innerHTML ='Tehdään uusi vuorolistapohja.';
google.script.run.withSuccessHandler(uudenvalmistelu).withFailureHandler(showError).doPohja($("#jaksu").val());
break
case "3": // Päivitä pohja
google.script.run.withSuccessHandler(updateTAA).withFailureHandler(showError).getOAuthToken();
break
case "4": // Tee CSV
google.script.run.withSuccessHandler(doCSV).withFailureHandler(showError).getOAuthToken();
break
case "5": // Liitetään listan tiedot kalenterikutsuihin aka julkaisu
google.script.run.withSuccessHandler(doJulkaisu).withFailureHandler(showError).getOAuthToken();
break
case "6": // Toteumat Sheet
$('div.blockMe').block({message: null,overlayCSS: { backgroundColor: '#fff' }});
document.getElementById('result').innerHTML ='Tehdään toteuma-sheet TVS-kansioon.';
google.script.run.withSuccessHandler(hyvinMeni).withFailureHandler(showError).doToteuma($("#startDate").val());
break
case "7": // Kuunnelma toteumat Sheet
$('div.blockMe').block({message: null,overlayCSS: { backgroundColor: '#fff' }});
document.getElementById('result').innerHTML ='Tehdään kuunnelmatoteuma-sheet TVS-kansioon.';
google.script.run.withSuccessHandler(hyvinMeni).withFailureHandler(showError).doStudioToteuma($("#startDate").val());
break
case "8": // Tee tai päivitä Ceiton TAA-pohja
google.script.run.withSuccessHandler(doCeiton).withFailureHandler(showError).getOAuthToken();
break
case "9": // Ceiton TAA-pohjasta CSV
google.script.run.withSuccessHandler(doCeitonCSV).withFailureHandler(showError).getOAuthToken();
break
}
}
// 1. Lataa excel kalenteriin
function loadExcel(token) { // Näkymä .setParent('TVS')
if (pickerApiLoaded && token) {
var picker = new google.picker.PickerBuilder()
.addView(new google.picker.DocsUploadView().setParent('0B3faoEDlK5jWT1lxZnQtU3lPNWs'))
//.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.hideTitleBar()
.setLocale('fi')
.setOrigin('
.setOAuthToken(token)
.setDeveloperKey(DEVELOPER_KEY)
.setCallback(loadExcelCallback)
.setSize(DIALOG_DIMENSIONS.width - 2,
DIALOG_DIMENSIONS.height - 2)
.build();
picker.setVisible(true);
} else {
showError('Teidostovalitsimen lataus epäonnistui.');
}
}
function loadExcelCallback(data) {
var action = data[google.picker.Response.ACTION];
if (action == google.picker.Action.PICKED) {
var doc = data[google.picker.Response.DOCUMENTS][0];
var id = doc[
google.script.run.withSuccessHandler(excelkalenteriin).withFailureHandler(showError).xlsxToSheet(id); // Ensin excel pitää muuttaa Sheetiksi
} else if (action == google.picker.Action.CANCEL) {
document.getElementById('result').innerHTML = 'Valinta keskeytettiin.';
}
}
function excelkalenteriin(id){
$('div.blockMe').block({message: null,overlayCSS: { backgroundColor: '#fff' }});
document.getElementById('result').innerHTML ='Ajetaan varaukset kalenteriin.';
google.script.run.withSuccessHandler(hyvinMeni).withFailureHandler(showError).fromExcel(id); // Nyt vasta Sheet kalenteriin
}
function uudenvalmistelu(id){
document.getElementById('result').innerHTML ='Päivitetään uusi listapohja';
google.script.run.withSuccessHandler(hyvinMeni).withFailureHandler(showError).updateTAA(id); // 2. Uusi TAA-pohja saa vuorot
}
function updateTAA(token) { // .setParent('0B3faoEDlK5jWRlctdUtFRVBheWM') 3. Käyttäjän valitseman TAA-pohjan päivitys
if (pickerApiLoaded && token) {
var picker = new google.picker.PickerBuilder()
.disableFeature(google.picker.Feature.NAV_HIDDEN)
.addView(new google.picker.DocsView(google.picker.ViewId.SPREADSHEETS)
.setParent('0B3faoEDlK5jWT1lxZnQtU3lPNWs')
.setIncludeFolders(true)
.setSelectFolderEnabled(true))
.setOrigin('
.hideTitleBar()
.setLocale('fi')
.setOAuthToken(token)
.setDeveloperKey(DEVELOPER_KEY)
.setCallback(updateTAACallback)
.setSize(DIALOG_DIMENSIONS.width - 2,
DIALOG_DIMENSIONS.height - 2)
.build();
picker.setVisible(true);
} else {
showError('Tiedostovalitsimen lataus epäonnistui.');
}
}
function updateTAACallback(data) {
var action = data[google.picker.Response.ACTION];
if (action == google.picker.Action.PICKED) {
var doc = data[google.picker.Response.DOCUMENTS][0];
var id = doc[
var title = doc[
$('div.blockMe').block({message: null,overlayCSS: { backgroundColor: '#fff' }});
document.getElementById('result').innerHTML = 'Päivitetään lista :'+ title;
google.script.run.withSuccessHandler(hyvinMeni).withFailureHandler(showError).updateTAA(id);
} else if (action == google.picker.Action.CANCEL) {
document.getElementById('result').innerHTML = 'Valinta keskeytettiin.';
}
}
function doCSV(token) { // 4. CSV-tiedoston tekeminen
if (pickerApiLoaded && token) {
var picker = new google.picker.PickerBuilder()
.addView(new google.picker.DocsView(google.picker.ViewId.SPREADSHEETS)
.setParent('0B3faoEDlK5jWT1lxZnQtU3lPNWs')
.setIncludeFolders(true)
.setSelectFolderEnabled(true))
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.setOrigin('
.hideTitleBar()
.setLocale('fi')
.setOAuthToken(token)
.setDeveloperKey(DEVELOPER_KEY)
.setCallback(doCSVCallback)
.setSize(DIALOG_DIMENSIONS.width - 2,
DIALOG_DIMENSIONS.height - 2)
.build();
picker.setVisible(true);
} else {
showError('Tiedostovalitsimen lataus epäonnistui.');
}
}
function doCSVCallback(data) {
var action = data[google.picker.Response.ACTION];
if (action == google.picker.Action.PICKED) {
var doc = data[google.picker.Response.DOCUMENTS][0];
var id = doc[
var title = doc[
$('div.blockMe').block({message: null,overlayCSS: { backgroundColor: '#fff' }});
document.getElementById('result').innerHTML = 'Tehdään CVS-tiedosto Hera-ajoa varten:'+ title;
google.script.run.withSuccessHandler(hyvinMeni).withFailureHandler(showError).toCSV(id);
} else if (action == google.picker.Action.CANCEL) {
document.getElementById('result').innerHTML = 'Valinta keskeytettiin.';
}
}
function doJulkaisu(token) { // 5. Vuorojen julkaisu kalentereihin
if (pickerApiLoaded && token) {
var picker = new google.picker.PickerBuilder()
.addView(new google.picker.DocsView(google.picker.ViewId.SPREADSHEETS)
.setParent('0BxT7kV9T1noJYjNPb2RybkExc0U') // Katsotaan aluksi vain Julkaistuts-kansioon.
.setIncludeFolders(true)
.setSelectFolderEnabled(true))
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.setOrigin('
.hideTitleBar()
.setLocale('fi')
.setOAuthToken(token)
.setDeveloperKey(DEVELOPER_KEY)
.setCallback(doJulkaisuCallback)
.setSize(DIALOG_DIMENSIONS.width - 2,
DIALOG_DIMENSIONS.height - 2)
.build();
picker.setVisible(true);
} else {
showError('Tiedostovalitsimen lataus epäonnistui.');
}
}
function doJulkaisuCallback(data) {
var action = data[google.picker.Response.ACTION];
if (action == google.picker.Action.PICKED) {
var doc = data[google.picker.Response.DOCUMENTS][0];
var id = doc[
var title = doc[
$('div.blockMe').block({message: null,overlayCSS: { backgroundColor: '#fff' }});
document.getElementById('result').innerHTML = 'Julkaistaan vuorot listalta: '+ title;
google.script.run.withSuccessHandler(doVPVL).withFailureHandler(showError).toCAL(id);
} else if (action == google.picker.Action.CANCEL) {
document.getElementById('result').innerHTML = 'Valinta keskeytettiin.';
}
}
function doVPVL(id){ // Vielä VPVL -kalenteri
document.getElementById('result').innerHTML ='Vielä VP,VL,TV,yms. tiedot kalenteriin.';
google.script.run.withSuccessHandler(hyvinMeni).withFailureHandler(showError).doVPVL(id);
}
function doCeiton(token) { // 8. Pickerille heitetään Ceitonin xls
if (pickerApiLoaded && token) {
var picker = new google.picker.PickerBuilder()
.addView(new google.picker.DocsUploadView().setParent('0B3faoEDlK5jWT1lxZnQtU3lPNWs'))
//.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.hideTitleBar()
.setLocale('fi')
.setOrigin('
.setOAuthToken(token)
.setDeveloperKey(DEVELOPER_KEY)
.setCallback(loadtoCeiton)
.setSize(DIALOG_DIMENSIONS.width - 2,
DIALOG_DIMENSIONS.height - 2)
.build();
picker.setVisible(true);
} else {
showError('Tiedostovalitsimen lataus epäonnistui.');}
}
function loadtoCeiton(data) { // Pickeriltä saadaan data-objekti
var action = data[google.picker.Response.ACTION];
if (action == google.picker.Action.PICKED) {
var doc = data[google.picker.Response.DOCUMENTS][0];
var id = doc[
$('div.blockMe').block({message: null,overlayCSS: { backgroundColor: '#fff' }});
document.getElementById('result').innerHTML ='CEITON-Liste wird als Arbeitszeit Autonomie-Liste geändert werden.';
google.script.run.withSuccessHandler(hyvinMeni).withFailureHandler(showError).CeitonxlsxToSheet(id); // Rullataan excelistä TAA-pohja.
} else if (action == google.picker.Action.CANCEL) {
document.getElementById('result').innerHTML = 'Valinta keskeytettiin.';
}
}
function doCeitonCSV(token) { // 9. Ceiton CSV-tiedoston tekeminen
if (pickerApiLoaded && token) {
var picker = new google.picker.PickerBuilder()
.addView(new google.picker.DocsView(google.picker.ViewId.SPREADSHEETS)
.setParent('0B3faoEDlK5jWT1lxZnQtU3lPNWs')
.setIncludeFolders(true)
.setSelectFolderEnabled(true))
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.setOrigin('
.hideTitleBar()
.setLocale('fi')
.setOAuthToken(token)
.setDeveloperKey(DEVELOPER_KEY)
.setCallback(doCeitonCSVCallback)
.setSize(DIALOG_DIMENSIONS.width - 2,
DIALOG_DIMENSIONS.height - 2)
.build();
picker.setVisible(true);
} else {
showError('Tiedostovalitsimen lataus epäonnistui.');
}
}
function doCeitonCSVCallback(data) {
var action = data[google.picker.Response.ACTION];
if (action == google.picker.Action.PICKED) {
var doc = data[google.picker.Response.DOCUMENTS][0];
var id = doc[
var title = doc[
$('div.blockMe').block({message: null,overlayCSS: { backgroundColor: '#fff' }});
document.getElementById('result').innerHTML = 'Ceiton CVS-tiedosto Hera-ajoa varten:'+ title;
google.script.run.withSuccessHandler(hyvinMeni).withFailureHandler(showError).CeitontoCSV(id);
} else if (action == google.picker.Action.CANCEL) {
document.getElementById('result').innerHTML = 'Valinta keskeytettiin.';
}
}
function hyvinMeni(){ // Kaikki meni OK
$('div.blockMe').unblock();
document.getElementById('result').innerHTML ='';
alert('Homma valmis!');
}
function showError(message) { // Jokin meni pieleen
$('div.blockMe').unblock();
document.getElementById('result').innerHTML = '';
alert('Virhe: ' + message);
}
function jaksota(){ // Jaksot ListBoksiin
var select = document.getElementById('jaksu');
var i;
for (i = 0; i < jaksot.length; i++) {
var el = document.createElement("option");
el.textContent = jaksot[i].toLocaleDateString();
el.value = jaksot[i];
select.appendChild(el);
}}
window.onload = jaksota;
$(function() { // Jaksonvalitsin
$('.date-picker').datepicker( {
changeMonth: true,
changeYear: true,
showButtonPanel: true,
dateFormat: 'm/yy',
maxDate: "+1M",
minDate: "-12M",
onClose: function(dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year, month, 1));
}
});
});
</script>
<style>
.ui-datepicker-calendar {
display: none;
}
.ui-datepicker {
width: 210px;
height: auto;
margin: 5px auto 0;
font: 9pt Arial, sans-serif;
-webkit-box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, .5);
-moz-box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, .5);
box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, .5);
}
</style>
</head>
<div class="blockMe">
<button style="width:210px" onclick='toiminnot("1")'>Lataa excelistä tiedot kalentereihin</button><br><br>
<select id="jaksu" dir="rtl" name="D1"></select>
<button style="width:120px" onclick='toiminnot("2")'>Luo uusi TAA-lista</button><br><br>
<button style="width:210px" onclick='toiminnot("3")'>Päivitä TAA-lista</button><br><br>
<button style="width:210px" onclick='toiminnot("4")'>Tee TAA-listasta Hera-tiedosto</button><br><br>
<button style="width:210px" onclick='toiminnot("5")'>Julkaise TAA-listan vuorot</button><br><br>
<input style="width:205px" name="startDate" id="startDate" class="date-picker" value="1/2015" /><br>
<button style="width:210px" onclick='toiminnot("6")'>Tarkkailutoteumat</button><br>
<button style="width:210px" onclick='toiminnot("7")'>Kuunnelmatoteumat</button>
<button style="width:210px" onclick='toiminnot("8")'>Aus Ceiton</button>
<button style="width:210px" onclick='toiminnot("9")'>Nach CSV</button>
</div>
<div>
<p id='result'></p>
</div>
</body>
</html>
sa...@in.g4s.com <sa...@in.g4s.com> #5
Hi Team ,
Please suggest any solution , i am also facing same issue from today. It stop supporting "google.script.run" from spreadsheet / form sheet. But it was working fine from last 2 years.
It is showing Error as below:
TypeError: google.script is undefined and Uncaught TypeError: Cannot read property 'run' of undefined
i am also added sample of my code :
if(statusname.length==1 && stepname.length==1){
google.script.run.withSuccessHandler(setOwner).getUserInfo();
}
Please suggest any quick solution as my application has more than 20k users.
Thanks
Please suggest any solution , i am also facing same issue from today. It stop supporting "google.script.run" from spreadsheet / form sheet. But it was working fine from last 2 years.
It is showing Error as below:
TypeError: google.script is undefined and Uncaught TypeError: Cannot read property 'run' of undefined
i am also added sample of my code :
if(statusname.length==1 && stepname.length==1){
google.script.run.withSuccessHandler(setOwner).getUserInfo();
}
Please suggest any quick solution as my application has more than 20k users.
Thanks
ma...@copa-webservices.de <ma...@copa-webservices.de> #6
In our Add-ons the drive picker does not work any longer..same error message:
Uncaught TypeError: Cannot read property 'host' of undefined
at createPicker (VM2242 userCodeAppPanel:76)
at Me (2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:52)
at 2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:6
at cg.J (2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:84)
at nd (2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:27)
at id (2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:28)
at 2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:25
createPicker @ VM2242 userCodeAppPanel:76
Me @ 2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:52
(anonymous) @ 2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:6
cg.J @ 2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:84
nd @ 2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:27
id @ 2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:28
(anonymous) @ 2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:25
Uncaught TypeError: Cannot read property 'host' of undefined
at createPicker (VM2242 userCodeAppPanel:76)
at Me (2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:52)
at 2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:6
at cg.J (2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:84)
at nd (2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:27)
at id (2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:28)
at 2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:25
createPicker @ VM2242 userCodeAppPanel:76
Me @ 2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:52
(anonymous) @ 2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:6
cg.J @ 2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:84
nd @ 2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:27
id @ 2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:28
(anonymous) @ 2483804561-mae_html_user_bin_i18n_mae_html_user__de.js:25
sa...@pladisglobal.com <sa...@pladisglobal.com> #7
Hi Team,
We are facing this issue over multiple applications build over appscript. It has become a priority1 incident for us.
Please let us know what actions are being taken and when this issue is going to resolve as its affecting thousands of users.
Thanks
We are facing this issue over multiple applications build over appscript. It has become a priority1 incident for us.
Please let us know what actions are being taken and when this issue is going to resolve as its affecting thousands of users.
Thanks
da...@pladisglobal.com <da...@pladisglobal.com> #8
Hi Google team....any updates on this issue....atleast acknowledge the same and let us know by when this would be fixed.
gu...@hmw.gr.jp <gu...@hmw.gr.jp> #9
It is a continuation report.
I deleted the code related to Google Picker from the program I created with HTML Service, and confirmed that this problem will not occur in google.script.run.
Therefore, I think that this problem is in google picker rather than google.script.run.
I deleted the code related to Google Picker from the program I created with HTML Service, and confirmed that this problem will not occur in google.script.run.
Therefore, I think that this problem is in google picker rather than google.script.run.
to...@yle.fi <to...@yle.fi> #10
My bet was also on the picker. It has caused trouble before.
What was the error in the logger without google.script.run call?
(I'm not able to debug at the moment..)
2017-04-07 15:35 GMT+03:00 <buganizer-system@google.com>:
What was the error in the logger without google.script.run call?
(I'm not able to debug at the moment..)
2017-04-07 15:35 GMT+03:00 <buganizer-system@google.com>:
al...@crusardi.net <al...@crusardi.net> #11
gu...@hmw.gr.jp
Tks for your message. You mention that the error is on the Picker code. Apparently most of us posting on this thread is having the error here with a code that had been working for months or years.
Can any one please let us know how to fix this. tks.
Tks for your message. You mention that the error is on the Picker code. Apparently most of us posting on this thread is having the error here with a code that had been working for months or years.
Can any one please let us know how to fix this. tks.
ru...@sinova.co <ru...@sinova.co> #12
Temporary solution,
At the moment the following url is not working well: <script type = "text / javascript" src = "https://apis.google.com/js/api.js?onload=onApiLoad "> </script>
SOLUTION:
To use Google Drive Picker use the following library: <script type = "text / javascript" src = "https://www.google.com/jsapi "> </script>, this library should be added in HEAD Of your Html and in the Javascript code add the following line of code outside the function window.onload or $(document).ready(function () {}):
"Google.load(" picker "," 1 ");"
It worked for me.
At the moment the following url is not working well: <script type = "text / javascript" src = "
SOLUTION:
To use Google Drive Picker use the following library: <script type = "text / javascript" src = "
"Google.load(" picker "," 1 ");"
It worked for me.
al...@crusardi.net <al...@crusardi.net> #13
Sorry ru...@sinova.co. I did not understand you response.
Can you please send full code example. tks.
Can you please send full code example. tks.
[Deleted User] <[Deleted User]> #14
Hey,
See the reference documentation herehttps://developers.google.com/loader/ for a bit more detail.
See the reference documentation here
ru...@sinova.co <ru...@sinova.co> #15
Good Morning,
Here's an example of the solution:
Https://script.google.com/a/macros/sos.com.co/s/AKfycbxdHgUW3zAqM8EkxN781wiC_5aazTZjN2hJdgi0iV706o35RaE/exec
In the following link you can see the source code of the project made in Google Apps Script:
Https://script.google.com/d/149PE_O_hLuW1CR-YsDn8hSc85mWqWra_GtPrls1Y162EkjfIoWJHvoEF/edit?usp=sharing
Here's an example of the solution:
In the following link you can see the source code of the project made in Google Apps Script:
[Deleted User] <[Deleted User]> #16
This is happening in our production app as well. Was working fine and now there is some conflict between Google picker and google.script.run and is affecting out 1.5 million users.
Any fix, Google?
Any fix, Google?
ja...@weisscohen.org <ja...@weisscohen.org> #17
I probably have the same issue since this morning on a script that has been functioning for months. My code gives me the Picker window but then leaves me with a blank window after I select the file.
Thanks ru...@sinova.co. I am doing something wrong and can't get your alternative library to work. I am running my script within a spreadsheet and don't have a doGet(). Here is my code below. I'm new to web scripting so any advice would be helpful.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons.css ">
<script type="text/javascript">
var DIALOG_DIMENSIONS = {
width: 600,
height: 425
};
var pickerApiLoaded = false;
function onApiLoad() {
gapi.load('picker', {
'callback': function() {
pickerApiLoaded = true;
}
});
google.script.run.withSuccessHandler(createPicker)
.withFailureHandler(showError).getOAuthToken();
}
function createPicker(token) {
if (pickerApiLoaded && token) {
var docsView = new google.picker.DocsView()
.setIncludeFolders(true)
**addMimeTypeHere**;
var picker = new google.picker.PickerBuilder()
.addView(docsView)
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.hideTitleBar()
.setSize(DIALOG_DIMENSIONS.width - 2, DIALOG_DIMENSIONS.height - 2)
.setOAuthToken(token)
.setCallback(pickerCallback)
.setOrigin('https://docs.google.com ')
.build();
picker.setVisible(true);
} else {
showError('Unable to load the file picker.');
}
}
/**
* A callback function that extracts the chosen document's metadata from the
* response object. For details on the response object, see
*https://developers.google.com/picker/docs/result
*
* @param {object} data The response object.
*/
function pickerCallback(data) {
var action = data[google.picker.Response.ACTION];
if (action == google.picker.Action.PICKED) {
var doc = data[google.picker.Response.DOCUMENTS][0];
var id = doc[google.picker.Document.ID ];
**googleScriptHere**
document.getElementById('result').innerHTML = id;
} else if (action == google.picker.Action.CANCEL) {
google.script.host.close();
}
}
function showError(message) {
document.getElementById('result').innerHTML = 'Error: ' + message;
}
</script>
</head>
<body>
<script type="text/javascript" src="https://apis.google.com/js/api.js?onload=onApiLoad "></script>
</body>
</html>
Thanks ru...@sinova.co. I am doing something wrong and can't get your alternative library to work. I am running my script within a spreadsheet and don't have a doGet(). Here is my code below. I'm new to web scripting so any advice would be helpful.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="
<script type="text/javascript">
var DIALOG_DIMENSIONS = {
width: 600,
height: 425
};
var pickerApiLoaded = false;
function onApiLoad() {
gapi.load('picker', {
'callback': function() {
pickerApiLoaded = true;
}
});
google.script.run.withSuccessHandler(createPicker)
.withFailureHandler(showError).getOAuthToken();
}
function createPicker(token) {
if (pickerApiLoaded && token) {
var docsView = new google.picker.DocsView()
.setIncludeFolders(true)
**addMimeTypeHere**;
var picker = new google.picker.PickerBuilder()
.addView(docsView)
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.hideTitleBar()
.setSize(DIALOG_DIMENSIONS.width - 2, DIALOG_DIMENSIONS.height - 2)
.setOAuthToken(token)
.setCallback(pickerCallback)
.setOrigin('
.build();
picker.setVisible(true);
} else {
showError('Unable to load the file picker.');
}
}
/**
* A callback function that extracts the chosen document's metadata from the
* response object. For details on the response object, see
*
*
* @param {object} data The response object.
*/
function pickerCallback(data) {
var action = data[google.picker.Response.ACTION];
if (action == google.picker.Action.PICKED) {
var doc = data[google.picker.Response.DOCUMENTS][0];
var id = doc[
**googleScriptHere**
document.getElementById('result').innerHTML = id;
} else if (action == google.picker.Action.CANCEL) {
google.script.host.close();
}
}
function showError(message) {
document.getElementById('result').innerHTML = 'Error: ' + message;
}
</script>
</head>
<body>
<script type="text/javascript" src="
</body>
</html>
ch...@gmail.com <ch...@gmail.com> #19
I'm happy to see that it's global issue as I'm facing it too
[Deleted User] <[Deleted User]> #20
Respectfully @labnol.org , that's a work-around (and a very legitimate one by the way), not a solution. This is a breaking change for many production apps - if indeed its a planned change. Right now, seems like a bug as it breaks working code.
ed...@gmail.com <ed...@gmail.com> #21
Here is some minimal code to produce the issue. It is spliced from google's documentation. The below code also breaks google.script.host.close(). I think it is related to the reference to api.js.
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons.css ">
<script>
// code spliced from:https://developers.google.com/apps-script/guides/dialogs#file-open_dialogs
function onApiLoad() {
gapi.load('picker', {'callback': function() {
pickerApiLoaded = true;
}});
}
</script>
</head>
<body>
<button onclick="google.script.run.testRunLog()"> Run test log</button>
<button onclick="google.script.host.close()"> Close</button>
</body>
<script src="https://apis.google.com/js/api.js?onload=onApiLoad "></script>
</html>
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<link rel="stylesheet" href="
<script>
// code spliced from:
function onApiLoad() {
gapi.load('picker', {'callback': function() {
pickerApiLoaded = true;
}});
}
</script>
</head>
<body>
<button onclick="google.script.run.testRunLog()"> Run test log</button>
<button onclick="google.script.host.close()"> Close</button>
</body>
<script src="
</html>
er...@motorolasolutions.com <er...@motorolasolutions.com> #22
I am also experiencing an issue and need this fixed asap
in...@s1electric.com <in...@s1electric.com> #23
Hi there,
Our company relies on this for daily use, we are unable to run anything for our employees if we cannot "Copy Folders"
Our company relies on this for daily use, we are unable to run anything for our employees if we cannot "Copy Folders"
st...@gmail.com <st...@gmail.com> #24
I have implemented the workaround in my webapps and add-ons and it works. Thanks !!!
Need Google answer to know if this is the new way of working or if they fix the bug.
Need Google answer to know if this is the new way of working or if they fix the bug.
ri...@gmail.com <ri...@gmail.com> #25
Need Google answer for the sudden change!
Aa...@fitura.ai <Aa...@fitura.ai> #26
We are also having this problem. This is a critical issue. We have commercial applications that have been withdrawn from the market. A solution is required immediately.
gu...@hmw.gr.jp <gu...@hmw.gr.jp> #27
>>#15
Good Solution !!
Good Solution !!
gu...@hmw.gr.jp <gu...@hmw.gr.jp> #29
>>#28
Confirm that the script of the Picker API using api.js also works now.
I think that I've recovered, but there is no announcement from Google.
Confirm that the script of the Picker API using api.js also works now.
I think that I've recovered, but there is no announcement from Google.
ry...@google.com <ry...@google.com> #30
Thank you for the reports. It appears that a bug was introduced on April 6th that adversely affected the https://apis.google.com/js/api.js library used with Google Picker in Apps Script and App Maker. The bug was removed on April 7th. Our engineers are investigating the problem to make sure it doesn't occur again.
ja...@weisscohen.org <ja...@weisscohen.org> #31
It looks like I am having the same problem as on April 7th again. Started at 4:48 Eastern U.S. Time. Anyone else?
[Deleted User] <[Deleted User]> #32
This problem has started happening again. I can confirm ja...@weisscohen.org
[Deleted User] <[Deleted User]> #33
I'm not confident anybody is looking at this issue given its marked as Fixed so I have re-reported it here:
https://issuetracker.google.com/issues/37546558
Please upvote that issue by starring it if it is affecting you.
Please upvote that issue by starring it if it is affecting you.
gu...@hmw.gr.jp <gu...@hmw.gr.jp> #34
Also, the same problem has recurred. How many times will you repeat the same thing?
Eliminate the person in charge who is causing this problem immediately.
How long will it take for the beta version?
Eliminate the person in charge who is causing this problem immediately.
How long will it take for the beta version?
am...@labnol.org <am...@labnol.org> #35
ek...@google.com <ek...@google.com> #36
I can confirm that the issue has appeared again, and we'll escalate this to the engineering team immediately. We'll post updates here as we have them.
[Deleted User] <[Deleted User]> #37
Thanks for the update Eric. Appreciate it.
ek...@google.com <ek...@google.com> #38
FYI, the cause of the problem is that when the Picker API loads into google.picker, it is currently overwriting google.script, so google.script.run() calls start failing.
As mentioned earlier, one workaround at the moment is to use the Google Loader (https://developers.google.com/loader/ ) instead of the Google API Client for JavaScript (https://developers.google.com/api-client-library/javascript/start/start-js ) to load the Picker API:
<script type="text/javascript" src="https://www.google.com/jsapi "></script>
<script>google.load("picker", "1", {callback:function(){...}});</script>
Another alternative is to just manually preserve and restore google.script when loading the Picker API:
window.script = google.script;
gapi.load('picker', '1', {callback: function() {
google.script = window.script;
// ...
}});
We've escalated this issue internally and we apologize the trouble this has caused.
As mentioned earlier, one workaround at the moment is to use the Google Loader (
<script type="text/javascript" src="
<script>google.load("picker", "1", {callback:function(){...}});</script>
Another alternative is to just manually preserve and restore google.script when loading the Picker API:
window.script = google.script;
gapi.load('picker', '1', {callback: function() {
google.script = window.script;
// ...
}});
We've escalated this issue internally and we apologize the trouble this has caused.
[Deleted User] <[Deleted User]> #39
@Erik
Thank you for the update. I guess the question for those of us who have implemented the workaround is there a reason to restore the original code once the issue is resolved. In your Google Apps Scripts documentation here:
https://developers.google.com/apps-script/guides/dialogs
You implemented the picker the using the Google API Client. We don't know if that's random or if the API Client method is considered to be the 'correct' way. This matters because we need to know which method will be maintained in the long term.
Thank you for the update. I guess the question for those of us who have implemented the workaround is there a reason to restore the original code once the issue is resolved. In your Google Apps Scripts documentation here:
You implemented the picker the using the Google API Client. We don't know if that's random or if the API Client method is considered to be the 'correct' way. This matters because we need to know which method will be maintained in the long term.
ek...@google.com <ek...@google.com> #40
@Benny, at the moment we aren't sure why the Loader works while the API Client doesn't, so it is perhaps not a permanent fix. Both methods are supported and correct, and we are working to fix the problem with the API client.
ek...@google.com <ek...@google.com> #41
The engineering team has located the source of the problem and has created a fix. We're working to push that fix to production, but we don't have a timeline as of yet.
[Deleted User] <[Deleted User]> #42
Thanks ek...@google.com . While this is quite affecting as an issue - especially with the recurrence - the communication and updates this time around are significantly better than the last time. Cheers.
Now, back to waiting for the fix to go live.
Now, back to waiting for the fix to go live.
ek...@google.com <ek...@google.com> #43
The fix has been pushed to production, with the last datacenters updating now. I'm not able to reproduce the problem any more, but let us know if you continue to see the problem.
[Deleted User] <[Deleted User]> #44
I'm glad to report this seems to be working now. Thanks much for the update ek...@google.com
Any background on why this is fragile and if the risk remains of breaking again? I only ask as engineering teams sometimes need to leave things non-permanently resolved due to roadmap priorities. It is good to know from the users' perspective so I can switch over to an alternate implementation (the one suggested a couple of times in this thread).
Any background on why this is fragile and if the risk remains of breaking again? I only ask as engineering teams sometimes need to leave things non-permanently resolved due to roadmap priorities. It is good to know from the users' perspective so I can switch over to an alternate implementation (the one suggested a couple of times in this thread).
ry...@google.com <ry...@google.com>
cl...@cybird.co.jp <cl...@cybird.co.jp> #45
I've encountered this issue today on a web apps script that has been working for weeks.
It seems to be caused by importing the charts API through the following:
<script src="https://www.gstatic.com/charts/loader.js "></script>
The "Google Loader" link provided above is dead.
It seems to be caused by importing the charts API through the following:
<script src="
The "Google Loader" link provided above is dead.
my...@mykaarma.com <my...@mykaarma.com> #46
It is happening with me too. Suddenly reports that were running fine just crapped out with same error. What should be the next steps here?
ya...@pezier.com <ya...@pezier.com> #47
Same issue here, and the workaround from 2017 doesn't seem to be working for me.
Description
0
down vote
favorite
I had a google apps script working fine for months and it suddenly stopped working. I'm wondering if Google deprecated some part of my code or something.
This is the link to the file: Click here to view Google Spreadsheet File
The google script code is apparently failing when trying to call a google script function from an HTML file. This is the line of code that fails.
google.script.run.importCSVData(id);
The lines fails and catches the following error:
TypeError: Cannot read property 'run' of undefined
Like I said, I had this code working fine for months and it suddenly stopped working.
(FYI... The purpose of this code is to upload a CSV file into the tab "Archivo Plano ADN". To run this code, one must simply select "Importar Archivo CSV" --> "Importar Archivo..." from the upper menu. When prompted to select file, select any .csv file. The csv file must be separated by ;)
My Google Spreadsheet File has three code files ("Code.gs", "CodeImport.gs" and "Picker.html")
Let me give you the code of each:
Code.gs:
function onOpen() {
var me = Session.getEffectiveUser();
if (me.getEmail() == "alejandro.sardi@crusardi.net") {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Protected Ranges')
.addItem('Remove Protection', 'menuItem1')
.addItem('Copy Protected Ranges To Another Sheet', 'menuItem2')
.addItem('Copy SM Protected Ranges to all SA sheets', 'menuItem3')
.addToUi();
ui.createMenu('Importar Archivo CSV')
.addItem('Importar Archivo...', 'showPicker')
.addToUi();
ui.cre
} else {
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.createMenu('Importar Archivo CSV')
.addItem('Importar Archivo...', 'showPicker')
.addToUi();
}
}
CodeImport.gs:
function importCSVData(id) {
try {
var file = DriveApp.getFileById(id);
var csvData = Utilities.parseCsv(file.getBlob().getDataAsString("ISO-8859-1"),";");
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Archivo Plano ADN");
sheet.getRange("A:U").clear();
sheet.getRange("G:G").setNumberFormat('@STRING@');
Logger.log("yes");
sheet.getRange(1, 1, csvData.length, csvData[0].length).setValues(csvData);
file.setTrashed(true);
SpreadsheetApp.getUi().alert("Archivo Importado con éxito");
} catch (e) {
MailApp.sendEmail(Session.getEffectiveUser().getEmail(), "Error report jaja - sonríele a la vida!",
"\r\nMessage: " + e.message
+ "\r\nFile: " + e.fileName
+ "\r\nLine: " + e.lineNumber);
}
}
function showPicker() {
var html = HtmlService.createHtmlOutputFromFile('Picker.html')
.setWidth(600)
.setHeight(425)
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
SpreadsheetApp.getUi().showModalDialog(html, 'Select File');
}
function getOAuthToken() {
DriveApp.getRootFolder();
return ScriptApp.getOAuthToken();
}
function finishedImport() {
SpreadsheetApp.getUi().alert("Archivo importado exitosamente");
}
function senderror(e) {
MailApp.sendEmail(Session.getEffectiveUser().getEmail(), "Error report jaja - sonríele a la vida!",
"\r\nMessage: " + e.message
+ "\r\nFile: " + e.fileName
+ "\r\nLine: " + e.lineNumber);
}
And finally, Picker.html file:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="
<script type="text/javascript">
var DIALOG_DIMENSIONS = {
width: 600,
height: 425
};
var pickerApiLoaded = false;
function onApiLoad() {
gapi.load('picker', {
'callback': function() {
pickerApiLoaded = true;
}
});
google.script.run.withSuccessHandler(createPicker)
.withFailureHandler(showError).getOAuthToken();
}
function createPicker(token) {
if (pickerApiLoaded && token) {
//var docsView = new google.picker.DocsView()
//.setIncludeFolders(true)
//.setMimeTypes('application/vnd.google-apps.folder')
//.setSelectFolderEnabled(true);
var uploadDocsView = new google.picker.DocsUploadView()
.setIncludeFolders(true)
//.setMimeTypes('application/vnd.google-apps.folder')
//.setSelectFolderEnabled(true);
var picker = new google.picker.PickerBuilder()
//.addView(docsView)
.addView(uploadDocsView)
//.setAppId("AIzaSyCZDa4JKKIOv2AF3QyrG8DnVOXmz27054o")
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.hideTitleBar()
.setSize(DIALOG_DIMENSIONS.width - 2, DIALOG_DIMENSIONS.height - 2)
.setOAuthToken(token)
.setCallback(pickerCallback)
.setOrigin('
.build();
picker.setVisible(true);
} else {
showError('Unable to load the file picker.');
}
}
/**
* A callback function that extracts the chosen document's metadata from the
* response object. For details on the response object, see
*
*
* @param {object} data The response object.
*/
function pickerCallback(data) {
try {
var action = data[google.picker.Response.ACTION];
if (action == google.picker.Action.PICKED) {
var doc = data[google.picker.Response.DOCUMENTS][0];
var id = doc[
// Show the ID of the Google Drive folder
//document.getElementById('result').innerHTML = id;
document.getElementById('result').innerHTML = "Importando..."
google.script.run.importCSVData(id);
//google.script.run.deleteImportedFile(id);
google.script.host.close();
} else if (action == google.picker.Action.CANCEL) {
//document.getElementById('result').innerHTML = "Cerrando1..."
google.script.host.close();
//document.getElementById('result').innerHTML = "Cerrando2..."
}
} catch (e) {
document.getElementById('result').innerHTML = e;
google.script.run.senderror(e);
}
}
function showError(message) {
document.getElementById('result').innerHTML = 'Error: ' + message;
}
</script>
</head>
<body>
<div>
<p id='result'></p>
</div>
<script type="text/javascript" src="
</body>
</html>