0

I stepped through this example to create a Google Apps Script. I've wired up the OAuth2 credentials from a 3rd party javascript application and tried to execute my google apps script via that app. Every time I attempt to it fails with

"error": {
"code":3
"message": "ScriptError",
"details":[{
"@type:": "type.googleapis.com/google.apps.script.v1.ExecutionError",
"errorMessage": Script function not found: setData",
"errorType": "ScriptError"}]}}

I've enabled the Apps Script API on this App Script and can see the logs of the execution failing from within my Drive. I'm connecting via a chrome extension which I created Oauth2 credentials for

Also the relevent function is named 'setData': function setData(parameters) {

If I look at the Execution Transcript on setData, I see it attempting to run:

[19-01-24 16:33:39:982 PST] Starting execution 
[19-01-24 16:33:39:988 PST] Execution failed: Script function not found: setData [0 seconds total runtime]

The cruel irony is that behind the modal i can see the function 'setData' sitting there

Please let me know how to debug this

plamb
  • 5,636
  • 1
  • 18
  • 31
  • Although I'm not sure whether this is related to your issue because I'm not sure about the detail of your situation, for example, can you confirm whether there is the function of ``setData()`` in the project that you set the project ID? – Tanaike Jan 25 '19 at 00:41
  • The relevant function is called setData. Where I think my issue may be is that I don't know how to set Oauth credentials for that specific project (resources > cloud platform project). When I am in that project's dashboard there is no area to create a new credential. I have to go to "APIs & Services" then credentials to create a new credential. Where is it that I set a project ID? – plamb Jan 25 '19 at 00:56
  • Thank you for replying. In your situation, 1. You have a project Google Apps Script and the project has the function ``setData()``. 2. The project of Google Apps Script is not linked to the project of Google Developer Console. If my understanding is correct, for example, how about using the Google Developer Console project linked to the existing GAS project? Or how about linking the Google Developer Console project you want to use to the the Google Developer Console project? But I'm not sure whether this is the direct solution. I apologize for this situation. – Tanaike Jan 25 '19 at 01:44
  • Do you have a good link for a tutorial on linking the Google Developer Console project to an existing GAS project? – plamb Jan 25 '19 at 02:08
  • How about this? https://developers.google.com/apps-script/guides/cloud-platform-projects#switch_to_a_different_google_cloud_platform_project By the way, can I ask you about wheter my understanding for your situation was correct? – Tanaike Jan 25 '19 at 02:22
  • So it looks like my App Script is connected to the project I want. Tell me if the credential steps I went through are right: 1.) go to API & Services -> Credentials -> Create Credentials -> Chrome app -> (add my chrome extensions ID to the APP ID URL) -> click create. Outside of that flow my credential(s) aren't linked to my App Script project in any way – plamb Jan 25 '19 at 02:31
  • About ``So it looks like my App Script is connected to the project I want.``, if the project of Google Developer Console is linked to the GAS project you want to run, I think that the error of ``Script function not found: setData`` doesn't occur. So I think that the current issue might be different from the issue I am thinking. I apologize for my poor skill. – Tanaike Jan 25 '19 at 02:43

1 Answers1

0

Okay so the problem was that when I first selected publish -> deploy as API executable on my Google Apps Script the name of my function was different. I thought by going through that flow again after changing it, namely, publish -> deploy as API executable was enough to update my function on the Apps Script API. In fact, I had to deploy a new version of the code inside of publish -> deploy as API executable. After doing this, my chrome extension successfully connected.

plamb
  • 5,636
  • 1
  • 18
  • 31